Class: Zoho::Inventory::API
- Inherits:
-
Object
- Object
- Zoho::Inventory::API
- Defined in:
- lib/zoho/inventory/api.rb
Constant Summary collapse
- BASE_URI =
'https://inventory.zoho.com/api/v1/'.freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #construct_uri(path = '') ⇒ Object
- #default_options ⇒ Object
-
#initialize(type:) ⇒ API
constructor
A new instance of API.
- #merge_options(options = {}) ⇒ Object
- #request(uri, method, params = {}) ⇒ Object
Constructor Details
#initialize(type:) ⇒ API
Returns a new instance of API.
11 12 13 |
# File 'lib/zoho/inventory/api.rb', line 11 def initialize(type:) @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/zoho/inventory/api.rb', line 9 def type @type end |
Instance Method Details
#construct_uri(path = '') ⇒ Object
15 16 17 |
# File 'lib/zoho/inventory/api.rb', line 15 def construct_uri(path = '') URI.parse("#{BASE_URI}#{type}#{path}#{config_uri}") end |
#default_options ⇒ Object
29 30 31 |
# File 'lib/zoho/inventory/api.rb', line 29 def { page: 1, per_page: Zoho.configuration.per_page } end |
#merge_options(options = {}) ⇒ Object
25 26 27 |
# File 'lib/zoho/inventory/api.rb', line 25 def ( = {}) .map { |key, value| "#{key}=#{value}" }.join('&') end |
#request(uri, method, params = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/zoho/inventory/api.rb', line 19 def request(uri, method, params = {}) response = HTTParty.send(method, uri, params) parse_result(response) end |