Class: Namely::ResourceGateway
- Inherits:
-
Object
- Object
- Namely::ResourceGateway
- Defined in:
- lib/namely/resource_gateway.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #create(attributes) ⇒ Object
-
#initialize(options) ⇒ ResourceGateway
constructor
A new instance of ResourceGateway.
- #json_index ⇒ Object
- #json_show(id) ⇒ Object
- #show_head(id) ⇒ Object
- #update(id, changes) ⇒ Object
Constructor Details
#initialize(options) ⇒ ResourceGateway
Returns a new instance of ResourceGateway.
5 6 7 8 9 10 |
# File 'lib/namely/resource_gateway.rb', line 5 def initialize() @access_token = .fetch(:access_token) @endpoint = .fetch(:endpoint) @subdomain = .fetch(:subdomain) @paged = .fetch(:paged, false) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
3 4 5 |
# File 'lib/namely/resource_gateway.rb', line 3 def endpoint @endpoint end |
Instance Method Details
#create(attributes) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/namely/resource_gateway.rb', line 24 def create(attributes) response = post( "/#{endpoint}", endpoint => [attributes] ) extract_id(response) end |
#json_index ⇒ Object
12 13 14 |
# File 'lib/namely/resource_gateway.rb', line 12 def json_index paged ? json_index_paged : json_index_all end |
#json_show(id) ⇒ Object
16 17 18 |
# File 'lib/namely/resource_gateway.rb', line 16 def json_show(id) get("/#{endpoint}/#{id}")[resource_name].first end |
#show_head(id) ⇒ Object
20 21 22 |
# File 'lib/namely/resource_gateway.rb', line 20 def show_head(id) head("/#{endpoint}/#{id}") end |
#update(id, changes) ⇒ Object
32 33 34 |
# File 'lib/namely/resource_gateway.rb', line 32 def update(id, changes) put("/#{endpoint}/#{id}", endpoint => [changes]) end |