Created
February 2, 2016 22:26
-
-
Save jbender/e459dd23ff03498b1338 to your computer and use it in GitHub Desktop.
Example RubyMotion Resource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ContactuallyApi | |
module Resources | |
module Contacts | |
RESOURCE_URL_BASE = 'api/v2/contacts'.freeze | |
def contact_index(params = nil, &block) | |
path = RESOURCE_URL_BASE | |
ContactuallyApi.client.get(path, params, &block) | |
end | |
def contact_create(data, &block) | |
path = RESOURCE_URL_BASE | |
params = { :data => data } | |
ContactuallyApi.client.post(path, params, &block) | |
end | |
def contact_show(id, &block) | |
path = "#{RESOURCE_URL_BASE}/#{id}" | |
ContactuallyApi.client.get(path, nil, &block) | |
end | |
def contact_update(id, data, &block) | |
path = "#{RESOURCE_URL_BASE}/#{id}" | |
params = { :data => data } | |
ContactuallyApi.client.patch(path, params, &block) | |
end | |
def contact_destroy(id, &block) | |
path = "#{RESOURCE_URL_BASE}/#{id}" | |
ContactuallyApi.client.delete(path, &block) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment