Class: Terracycle::Base
- Inherits:
-
Object
- Object
- Terracycle::Base
- Extended by:
- Forwardable
- Defined in:
- lib/terracycle/base.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#brigade(id, format) ⇒ Array
Terracycle.brigade_lists(“chip bag brigade”, “energy bar wrapper brigade”).
-
#collection_create(body = {}) ⇒ Object
Brigade/collection sign up.
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
-
#label_requests_show(id, format) ⇒ Array
The subscribers of the specified collection.
-
#label_show(id, format) ⇒ Array
Returns the subscribers of the specified labels.
-
#signup_create(user, email, first_mame, last_name, login, default_charity, password, password_confirmation, minimum_registration_age, terms) ⇒ Object
Signs up a new user .
-
#update_user(username, body = {}) ⇒ Object
Updates the authenticating user’s profile .
-
#user_collection(username, id, format) ⇒ Object
Returns a user’s collection.
-
#user_info(username, format) ⇒ Object
Returns extended information of a given user.
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/terracycle/base.rb', line 9 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/terracycle/base.rb', line 7 def client @client end |
Instance Method Details
#brigade(id, format) ⇒ Array
Terracycle.brigade_lists(“chip bag brigade”, “energy bar wrapper brigade”)
91 92 93 |
# File 'lib/terracycle/base.rb', line 91 def brigade(id, format) perform_get("/brigades/#{id}.#{format}", :mash => true) end |
#collection_create(body = {}) ⇒ Object
Brigade sign up is unlimited.
Brigade/collection sign up
Terracycle.brigade_lists(“chip bag brigade”, “energy bar wrapper brigade”)
133 134 135 136 |
# File 'lib/terracycle/base.rb', line 133 def collection_create(body = {}) perform_post("/collections/create.json", :body => body) end |
#label_requests_show(id, format) ⇒ Array
Returns The subscribers of the specified collection.
105 106 107 |
# File 'lib/terracycle/base.rb', line 105 def label_requests_show(id, format) perform_get("/label_requests/#{id}.#{format}", :mash => true) end |
#label_show(id, format) ⇒ Array
Returns the subscribers of the specified labels
119 120 121 |
# File 'lib/terracycle/base.rb', line 119 def label_show(id, format) perform_get("/labels/#{id}.#{format}") end |
#signup_create(user, email, first_mame, last_name, login, default_charity, password, password_confirmation, minimum_registration_age, terms) ⇒ Object
Signs up a new user
One of the following must be present: first name, last name - see api.terracycle.net/api_home/sign_up for complete list
22 23 24 25 26 |
# File 'lib/terracycle/base.rb', line 22 def signup_create(user, email, first_mame, last_name, login, default_charity, password, password_confirmation, minimum_registration_age, terms) perform_post("/users/create.json", :body => {:user => user, :email => email, :first_mame => first_mame, :last_name => last_name, :login => login, :default_charity => default_charity, :password => password, :password_confirmation => password_confirmation, :minimum_registration_age => minimum_registration_age, :terms => terms }) end |
#update_user(username, body = {}) ⇒ Object
This method asynchronously processes the uploaded file before updating the user’s profile.
Updates the authenticating user’s profile
One of the following must be present: first name, last name - see api.Terracycle.net/api_home/update_use for complete list
52 53 54 |
# File 'lib/terracycle/base.rb', line 52 def update_user(username, body={}) perform_post("/users/update/#{username}.json", :body => body) end |
#collections(options = {}) ⇒ Hashie::Mash #collections(user, options = {}) ⇒ Hashie::Mash
Returns a user’s collection
77 78 79 |
# File 'lib/terracycle/base.rb', line 77 def user_collection(username, id, format) perform_get("/users/#{username}/collections/#{id}.#{format}", :mash => false) end |
#user_info(username, format) ⇒ Object
Overload the method to allow fetching of the authenticated user’s user name from configuration.
Returns extended information of a given user
38 39 40 |
# File 'lib/terracycle/base.rb', line 38 def user_info(username, format) perform_get("/users/#{username}.#{format}", :mash => false) end |