Class: Zoho::Api::Addon
Constant Summary
collapse
- ATTRS =
[
:addon_code,
:name,
:unit_name,
:pricing_scheme,
:price_brackets,
:type,
:applicable_to_all_plans,
:product_id,
:description
]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Request
#attributes, #delete, delete, #get, get, #initialize, #post, post, #put, put
Constructor Details
This class inherits a constructor from Zoho::Request
Class Method Details
.all ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/zoho/api/addon.rb', line 29
def all
base_url = Zoho::Api::HOST+"/api/v1/addons"
response = get(base_url)
if response.code == 0
return response.addons
else
return response
end
end
|
.create(attrs = {}) ⇒ Object
39
40
41
42
|
# File 'lib/zoho/api/addon.rb', line 39
def create(attrs={})
addon = Zoho::Api::Addon.new(attrs)
return addon.save
end
|
.destroy(addon_id) ⇒ Object
69
70
71
72
73
|
# File 'lib/zoho/api/addon.rb', line 69
def destroy addon_id
base_url = Zoho::Api::HOST+"/api/v1/addons/#{addon_id}"
response = Zoho::Request.delete(base_url)
return response
end
|
.find(addon_id) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/zoho/api/addon.rb', line 44
def find addon_id
base_url = Zoho::Api::HOST+"/api/v1/addons/#{addon_id}"
response = get(base_url)
if response.code == 0
return response.addon
else
return nil
end
end
|
.update(addon_id, attrs = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/zoho/api/addon.rb', line 54
def update addon_id, attrs={}
addon = Zoho::Api::Addon.new(attrs)
base_url = Zoho::Api::HOST+"/api/v1/addons/#{addon_id}"
response = put(base_url) do |http, request|
request.body = addon.to_json
response = http.request(request)
response = JSON.parse(response.body, object_class: OpenStruct)
end
if response.code == 0
return response
else
return response
end
end
|
Instance Method Details
#save ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/zoho/api/addon.rb', line 18
def save
base_url = Zoho::Api::HOST+"/api/v1/addons"
response = post(base_url) do |http, request|
request.body = self.to_json
response = http.request(request)
response = JSON.parse(response.body, object_class: OpenStruct)
end
return response
end
|