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 |
# File 'lib/namely/resource_gateway.rb', line 5 def initialize() @access_token = .fetch(:access_token) @endpoint = .fetch(:endpoint) @subdomain = .fetch(:subdomain) 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
23 24 25 26 27 28 29 |
# File 'lib/namely/resource_gateway.rb', line 23 def create(attributes) response = post( "/#{endpoint}", endpoint => [attributes] ) extract_id(response) end |
#json_index ⇒ Object
11 12 13 |
# File 'lib/namely/resource_gateway.rb', line 11 def json_index get("/#{endpoint}", limit: :all)[resource_name] end |
#json_show(id) ⇒ Object
15 16 17 |
# File 'lib/namely/resource_gateway.rb', line 15 def json_show(id) get("/#{endpoint}/#{id}")[resource_name].first end |
#show_head(id) ⇒ Object
19 20 21 |
# File 'lib/namely/resource_gateway.rb', line 19 def show_head(id) head("/#{endpoint}/#{id}") end |
#update(id, changes) ⇒ Object
31 32 33 |
# File 'lib/namely/resource_gateway.rb', line 31 def update(id, changes) put("/#{endpoint}/#{id}", endpoint => [changes]) end |