CloudPlugs REST Library  1.0.0
for Objective-C
CloudPlugsRestClient Class Reference
Inheritance diagram for CloudPlugsRestClient:

Instance Methods

(CloudPlugsRequest *) - enrollProductWithModel:hwid:password:props:completionHandler:
 
(CloudPlugsRequest *) - enrollPrototypeWithHWid:password:name:perm:props:completionHandler:
 
(CloudPlugsRequest *) - enrollCtrlWithModel:ctrl:password:hwid:name:completionHandler:
 
(CloudPlugsRequest *) - controlDeviceWithModel:ctrl:password:completionHandler:
 
(CloudPlugsRequest *) - uncontrolDeviceWithPlugId:plugid_controlled:completionHandler:
 
(CloudPlugsRequest *) - getDevice:completionHandler:
 
(CloudPlugsRequest *) - getDeviceProp:prop:completionHandler:
 
(CloudPlugsRequest *) - setDeviceProp:prop:value:completionHandler:
 
(CloudPlugsRequest *) - removeDeviceProp:prop:completionHandler:
 
(CloudPlugsRequest *) - setDevice:perm:name:status:props:completionHandler:
 
(CloudPlugsRequest *) - unenroll:completionHandler:
 
(CloudPlugsRequest *) - getChannel:before:after:at:of:offset:limit:completionHandler:
 
(CloudPlugsRequest *) - retrieveDataFrom:before:after:at:of:offset:limit:completionHandler:
 
(CloudPlugsRequest *) - publishData:body:completionHandler:
 
(CloudPlugsRequest *) - removeData:withId:before:after:at:of:limit:completionHandler:
 
(CloudPlugsRequest *) - setDeviceLocation:longitude:latitude:altitude:accuracy:timestamp:completionHandler:
 
(CloudPlugsRequest *) - getDeviceLocation:completionHandler:
 

Properties

NSURL * baseUrl
 
NSString * authId
 
NSString * authPass
 
BOOL authMaster
 
double timeout
 

Method Documentation

◆ controlDeviceWithModel:ctrl:password:completionHandler:()

- (CloudPlugsRequest*) controlDeviceWithModel: (NSString *)  model
ctrl: (NSString *)  ctrl
password: (NSString *)  password
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for enrolling an already existent controller device

Parameters
modelThe model id of the device to control.
ctrlThe serial number (hwid) of the device to control.
passwordThe device password's
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ enrollCtrlWithModel:ctrl:password:hwid:name:completionHandler:()

- (CloudPlugsRequest*) enrollCtrlWithModel: (NSString *)  model
ctrl: (NSString *)  ctrl
password: (NSString *)  password
hwid: (NSString *)  hwid
name: (NSString *)  name
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for enrolling a new or already existent controller device.

Parameters
modelThe model id of the device to control.
ctrlThe serial number (hwid) of the device to control.
passwordThe device password's
hwidIf not NULL, then set unique string to identify this controller device
nameIf not NULL, then set the name of this device
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ enrollProductWithModel:hwid:password:props:completionHandler:()

- (CloudPlugsRequest*) enrollProductWithModel: (NSString *)  model
hwid: (NSString *)  hwid
password: (NSString *)  password
props: (NSDictionary *)  props
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for enrolling a new production device.

Parameters
modelThe device model's.
hwidThe serial number.
passwordThe password.
propsIf not NULL, then initialize the custom properties.
handlerCallback function. If not NULL it will receive the Request and its Response
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ enrollPrototypeWithHWid:password:name:perm:props:completionHandler:()

- (CloudPlugsRequest*) enrollPrototypeWithHWid: (NSString *)  hwid
password: (NSString *)  password
name: (NSString *)  name
perm: (NSDictionary *)  perm
props: (NSDictionary *)  props
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for enrolling a prototype

Parameters
hwidIf NULL, then it will be set as a random unique string.
passwordIf NULL, then set as the X-Plug-Master of the company
nameThe name of the product.
permIf NULL, then permit all.
propsIf not NULL, then initialize the custom properties.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ getChannel:before:after:at:of:offset:limit:completionHandler:()

- (CloudPlugsRequest*) getChannel: (NSString *)  channelMask
before: (id)  before
after: (id)  after
at: (id)  at
of: (id)  of
offset: (NSInteger)  offset
limit: (NSInteger)  limit
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for retrieving list channels/channels about already published data

Parameters
channelMaskThe channel mask.
before: TIMESTAMP || PLUG_ID, Optional, timestamp valid if greater than zero or OID of published data
after: TIMESTAMP || PLUG_ID, Optional, timestamp valid if greater than zero or OID of published data
at: TIMESTAMP_CSV || [TIMESTAMP,...], Optional, timestamp valid if greater than zero //TODO TIMESTAMP_CSV&?
of: "PLUG_ID_CSV" || ["PLUG_ID",...], Optional, plugid cvs
offset: N
limit: N
handlerCallback function. If not NULL it will receive the Request and its Response
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
CP_SUCCESS if the request succeeds, CP_FAILED otherwise.

◆ getDevice:completionHandler:()

- (CloudPlugsRequest*) getDevice: (NSString *)  plugid
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for reading a device.

Parameters
plugidThe plug-id of the device.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ getDeviceLocation:completionHandler:()

- (CloudPlugsRequest*) getDeviceLocation: (NSString *)  plugid
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for writing or deleting device location

Parameters
plugidIf not NULL, then the plug-id of the device, otherwise the device referenced in the session.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ getDeviceProp:prop:completionHandler:()

- (CloudPlugsRequest*) getDeviceProp: (NSString *)  plugid
prop: (NSString *)  prop
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for reading the device properties

Parameters
plugidThe plug-id of the device.
propIf NULL, then all properties value; otherwise the single property value.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ publishData:body:completionHandler:()

- (CloudPlugsRequest*) publishData: (NSString *)  channel
body: (id)  body
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for publishing data

Parameters
channelA optional channel, if NULL data need to contain a couple "channel":"channel"
bodyA json object or an array of objects like this: { "id" : “PLUG_ID”, "channel" : “CHANNEL”, // optional, to override the channel in the url "data" : JSON, "at" : TIMESTAMP, "of" : "PLUG_ID", // optional, check if the X-Plug-Id is authorized for setting this field "is_priv" : BOOLean, // optional, default false "expire_at" : TIMESTAMP, // optional, expire date of this data entry "ttl" : Number // optional, how many seconds this data entry will live (if "expire_at" is present, then this field is ignored) }
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ removeData:withId:before:after:at:of:limit:completionHandler:()

- (CloudPlugsRequest*) removeData: (NSString *)  channelMask
withId: (id)  _id
before: (id)  before
after: (id)  after
at: (id)  at
of: (id)  of
limit: (NSInteger)  limit
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for deleting already published data

Parameters
channelMaskThe channel mask
_id
before
after
at
of
limit
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ removeDeviceProp:prop:completionHandler:()

- (CloudPlugsRequest*) removeDeviceProp: (NSString *)  plugid
prop: (NSString *)  prop
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for deleting device property

Parameters
plugidThe plug-id of the device.
propThe single property value to be remove.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ retrieveDataFrom:before:after:at:of:offset:limit:completionHandler:()

- (CloudPlugsRequest*) retrieveDataFrom: (NSString *)  channelMask
before: (NSDate *)  before
after: (NSDate *)  after
at: (NSDate *)  at
of: (id)  of
offset: (NSInteger)  offset
limit: (NSInteger)  limit
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for retrieving already published data

Parameters
channelMaskThe channel mask.
beforeOptional, timestamp valid if greater than zero
afterOptional, timestamp valid if greater than zero
atOptional, timestamp valid if greater than zero
ofOptional, plugid cvs
offsetOptional
limitOptional
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ setDevice:perm:name:status:props:completionHandler:()

- (CloudPlugsRequest*) setDevice: (NSString *)  plugid
perm: (NSDictionary *)  perm
name: (NSString *)  name
status: (NSString *)  status
props: (NSDictionary *)  props
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for modifying a device

Parameters
plugidThe plug-id of the device.
perm: PERM_FILTER, // optional, it contains just the sharing filters to modify
name: String, // optional
status: STATUS, // optional
props: Object // optional, it contains just the properties to modify
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ setDeviceLocation:longitude:latitude:altitude:accuracy:timestamp:completionHandler:()

- (CloudPlugsRequest*) setDeviceLocation: (NSString *)  plugid
longitude: (double)  longitude
latitude: (double)  latitude
altitude: (double)  altitude
accuracy: (double)  accuracy
timestamp: (NSDate *)  timestamp
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for writing or deleting device location

Parameters
plugidIf not NULL, then the plug-id of the device, otherwise the device referenced in the session.
longitude
latitude
altitude
accuracy
timestamp
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ setDeviceProp:prop:value:completionHandler:()

- (CloudPlugsRequest*) setDeviceProp: (NSString *)  plugid
prop: (NSString *)  prop
value: (id)  value
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for writing or deleting device properties

Parameters
plugidThe plug-id of the device.
propIf NULL, then value must be an object; otherwise the single property value is written.
valueA json value, use null to delete one or all device properties.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ uncontrolDeviceWithPlugId:plugid_controlled:completionHandler:()

- (CloudPlugsRequest*) uncontrolDeviceWithPlugId: (NSString *)  plugid
plugid_controlled: (id)  plugidControlled
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for uncontrolling a device

Parameters
plugidIf NULL, then is the plug-id in the session.
plugidControlledIf not NULL, then the device(s) to uncontroll (default all associated devices).
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

◆ unenroll:completionHandler:()

- (CloudPlugsRequest*) unenroll: (id)  plugid
completionHandler: (void(^)(CloudPlugsRequest *, CloudPlugsResponse *))  handler 

This function performs an HTTP request to the server for removing any device (development, product or controller)

Parameters
plugidThe plug-ids csv of the device(s) to remove; if NULL then remove the device referenced in the session.
handlerCallback function. If not NULL it will receive the Request and its Response
Returns
TRUE if the request succeeds, FALSE otherwise.

Property Documentation

◆ authId

- (NSString*) authId
readwriteatomicstrong

The authentication id (plug-id or email) of the session.

◆ authMaster

- (BOOL) authMaster
readwriteatomicassign

The authentication mode in the session.

◆ authPass

- (NSString*) authPass
readwriteatomicstrong

The authentication password of the session.

◆ baseUrl

- (NSURL*) baseUrl
readwriteatomicstrong

Base url value for HTTP REST requests.

◆ timeout

- (double) timeout
readwriteatomicassign

Timeout value for requests in the session.