Class: ZohoInventory::ZohoObject
- Inherits:
-
Object
- Object
- ZohoInventory::ZohoObject
show all
- Extended by:
- Request
- Defined in:
- lib/zoho_inventory/zoho_object.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Methods included from Request
request
Instance Attribute Details
#values ⇒ Object
Returns the value of attribute values.
7
8
9
|
# File 'lib/zoho_inventory/zoho_object.rb', line 7
def values
@values
end
|
Class Method Details
.accept_api_methods(methods) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/zoho_inventory/zoho_object.rb', line 15
def self.accept_api_methods(methods)
@list = methods.include? :list
@create = methods.include? :create
@retrieve = methods.include? :retrieve
@update = methods.include? :update
@delete = methods.include? :delete
end
|
.api_methods ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/zoho_inventory/zoho_object.rb', line 23
def self.api_methods
{
list: @list,
create: @create ,
retrieve: @retrieve,
update: @update,
delete: @delete
}
end
|
.build_url_from_path(path, query_params = {}) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/zoho_inventory/zoho_object.rb', line 45
def self.build_url_from_path(path, query_params = {})
api_base = ZohoInventory.api_base
organization_id, auth_token = ZohoInventory.credentials
query_params.merge!({ authtoken: auth_token, organization_id: organization_id })
encoded_params = URI.encode_www_form(query_params)
"#{api_base}#{path}?#{encoded_params}"
end
|
.create(params = {}) ⇒ Object
66
67
68
69
|
# File 'lib/zoho_inventory/zoho_object.rb', line 66
def self.create(params = {})
check_authorized_methods(:create)
request(:post, resource_url, object_key, params)
end
|
.delete(id) ⇒ Object
81
82
83
84
|
# File 'lib/zoho_inventory/zoho_object.rb', line 81
def self.delete(id)
check_authorized_methods(:delete)
request(:delete, "#{resource_url}/#{id}")
end
|
.list ⇒ Object
61
62
63
64
|
# File 'lib/zoho_inventory/zoho_object.rb', line 61
def self.list
check_authorized_methods(:list)
request(:get, resource_url, self::OBJECT_NAME)
end
|
.object_key ⇒ Object
57
58
59
|
# File 'lib/zoho_inventory/zoho_object.rb', line 57
def self.object_key
Util.remote_object_key[self::OBJECT_NAME]
end
|
.resource_url ⇒ Object
53
54
55
|
# File 'lib/zoho_inventory/zoho_object.rb', line 53
def self.resource_url
"/v1/#{self::OBJECT_NAME}s"
end
|
.retrieve(id) ⇒ Object
71
72
73
74
|
# File 'lib/zoho_inventory/zoho_object.rb', line 71
def self.retrieve(id)
check_authorized_methods(:retrieve)
request(:get, "#{resource_url}/#{id}", self::OBJECT_NAME)
end
|
.update(id, params = {}) ⇒ Object
76
77
78
79
|
# File 'lib/zoho_inventory/zoho_object.rb', line 76
def self.update(id, params = {})
check_authorized_methods(:update)
request(:put, "#{resource_url}/#{id}", object_key, params)
end
|