For all the API calls, you must first obtain an access token. The access token is used to create an instance of the SDK which allows you to access the SDk methods.
Code Sample
SdkClient.new(session[:access_token])
createContact
API allows you to create a new contact.
Code Sample
begin
contact = params[:contact]
entry = client.createContact(contact)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{e}"
else
return html_page "#{e}"
end
end
Class Method
def createContact(contactsdata)
params = contactsdata
headers = {'Content-Type' => 'application/json'}
response = @session.do_post "contacts", params, headers
Sdk::parse_response(response, raw=true)
end
Example Return Response
{
"version": 0,
"id": "string"
}
deleteConatct
API allows you to delete specified contact.
Code Sample
begin
contactID = params[:contactID] || ''
entry = client.deleteConatct(contactID)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{e}"
else
return html_page "#{e}"
end
end
Class Method
def deleteContact(contactID)
response = @session.do_delete_without_params "contacts/#{contactID}"
Sdk::parse_response(response, raw=true)
end
contacts
API retrieves all contacts or a subset of contacts stored in a user’s Personal Cloud Storage account.
Code Sample
begin
path = params[:path] || '/contact'
if params[:query] != ''
query = params[:query]
end
if params[:sort] != ''
sort = params[:sort]
end
if params[:page] != ''
page = params[:page]
end
if params[:count] != ''
count = params[:count]
end
entry = client.contacts(query,sort,page,count)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
return html_page "#{e}"
end
Class Method
def contacts(query,sort,page,count)
params = {
"query" => query,
"sort" => sort,
"page" => page,
"count" => count
}
response = @session.do_get "contacts", params
Sdk::parse_response(response)
end
Example Return Response
{
"contactsResponse": {
"account": {
"userid": "string",
"addrbook": {
"updated": "string",
"contacts": {
"itemcount": 0,
"contact": [{
"firstname": "string",
"lastname": "string",
"middlename": "string",
"nameprefix": "string",
"namesuffix": "string",
"nickname": "string",
"birthday": "string",
"anniversary": "string",
"spouse": "string",
"children": "string",
"orgname": "string",
"orgunit": "string",
"jobtitle": "string",
"profession": "string",
"assistant": "string",
"gender": "string",
"relationship": "string",
"maritalstatus": "string",
"source": "string",
"note": "string",
"created": "string",
"modified": "string",
"incaseofemergency": false,
"favorite": false,
"tel": [{
"type": "string",
"indx": 0,
"number": "string",
"preference": 0
}],
"email": [{
"type": "string",
"indx": 0,
"address": "string",
"preference": 0
}],
"address": [{
"type": "string",
"indx": 0,
"pobox": "string",
"street": "string",
"apartment": "string",
"city": "string",
"state": "string",
"zipcode": "string",
"country": "string",
"preference": 0
}],
"im": [{
"type": "string",
"address": "string",
"preference": 0
}],
"version": 0,
"id": "string"
}]
}
}
}
}
}
Return Parameters
userid
- User ID of the logged-in userupdated
- The date of the last update to contactscontact
- Array of contactsupdateContact
API allows you to update specified contact.
Code Sample
begin
contactID = params[:contactID] || ''
updateContact = params[:updatecontact] || ''
entry = client.updateContact(contactID,updateContact)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{e}"
else
return html_page "#{e}"
end
end
Class Method
def updateContact(contactID,contact_updateddata)
params = contact_updateddata
headers = {'Content-Type' => 'application/json'}
response = @session.do_put "contacts/#{contactID}", params, headers
Sdk::parse_response(response,raw=true)
end
Example Return Response
{
"version": 0,
"id": "string"
}
NOTE: This SDK returns a maximum of 200 contacts in a successful response.
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.