zoho_ruby 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/README.md +4 -1
- data/docs/inventory/README.md +3 -0
- data/docs/inventory/items.md +102 -0
- data/lib/zoho/inventory/item.rb +35 -6
- data/lib/zoho/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d9eb280fbaf34cbf7ae8fce708a9bda910bb2b
|
4
|
+
data.tar.gz: aa3c96ae047f29633d3488a67d17b3838d09f017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d616c5b9ea1b87b90b243c4b658ec1d7f9229742325b4453708cdcad8788184da60a2d9e00d3e345a4f7f92ab255a10eb7a79c5538ac5a29b1e435e59ff8ca39
|
7
|
+
data.tar.gz: 2374511457f3b55997ec53f48cf801376d7d47d39e1a549e182b2674b998802d5bed1fa2af56dcdaae4bf48fc6fed151794a9ef787930983bb43b3213512564c
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ If you have the `organization_id` and `auth_token` already, here's what you need
|
|
27
27
|
Zoho.configure do |config|
|
28
28
|
config.organization_id = 'your_organization_id'
|
29
29
|
config.auth_token = 'your_auth_token'
|
30
|
-
config.per_page = 20
|
30
|
+
config.per_page = 20 # Default and maximum items per page is 200
|
31
31
|
end
|
32
32
|
```
|
33
33
|
## Usage
|
data/docs/README.md
CHANGED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Items
|
2
|
+
|
3
|
+
An item is the product that is offered for sale. Nature of the product could be physical or digital. Based on the type of your business, you can offer one or more goods/services. Your product can be either fixed priced or a subscription service. Each of this may fall under a separate pricing category or have add ons associated to them. For more details check https://www.zoho.com/inventory/api/v1/#Items
|
4
|
+
|
5
|
+
##### Create an item
|
6
|
+
|
7
|
+
Creates a new item in Zoho Inventory.
|
8
|
+
|
9
|
+
<!-- {.file-heading} -->
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
params = { name: 'Bags-small', rate: 10, purchase_rate: 10 }
|
13
|
+
|
14
|
+
Zoho::Inventory::Item.new.create(params)
|
15
|
+
```
|
16
|
+
Check https://www.zoho.com/inventory/api/v1/#Items_Create_an_item for more arguments that you can pass as params.
|
17
|
+
|
18
|
+
##### Retrieve an item
|
19
|
+
|
20
|
+
Fetches the details for an existing item.
|
21
|
+
|
22
|
+
<!-- {.file-heading} -->
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
item_id = '1234567890'
|
26
|
+
|
27
|
+
Zoho::Inventory::Items.new.find(item_id)
|
28
|
+
```
|
29
|
+
|
30
|
+
##### Update an item
|
31
|
+
|
32
|
+
Update the details of an item.
|
33
|
+
|
34
|
+
<!-- {.file-heading} -->
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
item_id = '1234567890'
|
38
|
+
params = { name: 'Bags small', rate: 5 }
|
39
|
+
|
40
|
+
Zoho::Inventory::Item.new.update(item_id, params)
|
41
|
+
```
|
42
|
+
Check https://www.zoho.com/inventory/api/v1/#Items_Update_an_item for more arguments that you can pass as params.
|
43
|
+
|
44
|
+
##### Delete an item
|
45
|
+
|
46
|
+
Deletes an existing item from Zoho Inventory.
|
47
|
+
|
48
|
+
<!-- {.file-heading} -->
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
item_id = '1234567890'
|
52
|
+
|
53
|
+
Zoho::Inventory::Item.new.destroy(item_id)
|
54
|
+
```
|
55
|
+
|
56
|
+
##### Mark as active
|
57
|
+
|
58
|
+
Changes the status of an item to active.
|
59
|
+
|
60
|
+
<!-- {.file-heading} -->
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
item_id = '1234567890'
|
64
|
+
|
65
|
+
Zoho::Inventory::Item.new.active!(item_id)
|
66
|
+
```
|
67
|
+
|
68
|
+
##### Mark as inactive
|
69
|
+
|
70
|
+
Mark an item as inactive.
|
71
|
+
|
72
|
+
<!-- {.file-heading} -->
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
item_id = '1234567890'
|
76
|
+
|
77
|
+
Zoho::Inventory::Item.new.inactive!(item_id)
|
78
|
+
```
|
79
|
+
|
80
|
+
##### List all the items
|
81
|
+
|
82
|
+
Lists all the items present in Zoho Inventory.
|
83
|
+
|
84
|
+
<!-- {.file-heading} -->
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
Zoho::Inventory.new.all
|
88
|
+
```
|
89
|
+
|
90
|
+
##### List all the items based on arguments passed
|
91
|
+
|
92
|
+
<!-- {.file-heading} -->
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
Zoho::Inventory.new
|
96
|
+
.where(filter_by: 'Status.Active', sort_column: 'created_time'
|
97
|
+
sort_order: 'D', search_text: 'Bags')
|
98
|
+
|
99
|
+
# filter_by (`Status.All`, `Status.Active`, `Status.Inactive`)
|
100
|
+
# sort_column (`name`, `rate`, `created_time`)
|
101
|
+
# sort_order ('D', 'A')
|
102
|
+
```
|
data/lib/zoho/inventory/item.rb
CHANGED
@@ -13,9 +13,9 @@ module Zoho
|
|
13
13
|
|
14
14
|
def all
|
15
15
|
uri = "#{BASE_URI}#{config_uri}&page=#{@page}" \
|
16
|
-
"&per_page=#{Zoho.configuration.per_page}"
|
16
|
+
"&per_page=#{Zoho.configuration.per_page}"
|
17
17
|
|
18
|
-
|
18
|
+
return_items_with_image_link(uri)
|
19
19
|
end
|
20
20
|
|
21
21
|
def where(**args)
|
@@ -25,25 +25,31 @@ module Zoho
|
|
25
25
|
uri << sort_uri(args[:sort_column], args[:sort_order])
|
26
26
|
uri << search_uri(args[:search_text])
|
27
27
|
|
28
|
-
|
28
|
+
return_items_with_image_link(uri)
|
29
29
|
end
|
30
30
|
|
31
31
|
def create(params)
|
32
32
|
uri = "#{BASE_URI}#{config_uri}"
|
33
|
+
result = request_item('post', uri, body: { JSONString: params.to_json })
|
34
|
+
add_image_link(result[:item]) if result[:item]
|
33
35
|
|
34
|
-
|
36
|
+
result
|
35
37
|
end
|
36
38
|
|
37
39
|
def update(item_id, params)
|
38
40
|
uri = "#{BASE_URI}/#{item_id}#{config_uri}"
|
41
|
+
result = request_item('put', uri, body: { JSONString: params.to_json })
|
42
|
+
add_image_link(result[:item]) if result[:item]
|
39
43
|
|
40
|
-
|
44
|
+
result
|
41
45
|
end
|
42
46
|
|
43
47
|
def find(item_id)
|
44
48
|
uri = "#{BASE_URI}/#{item_id}#{config_uri}"
|
49
|
+
result = request_item('get', uri)
|
50
|
+
add_image_link(result[:item]) if result[:item]
|
45
51
|
|
46
|
-
|
52
|
+
result
|
47
53
|
end
|
48
54
|
|
49
55
|
def destroy(item_id)
|
@@ -87,6 +93,29 @@ module Zoho
|
|
87
93
|
text.nil? ? '' : "&search_text=#{text}"
|
88
94
|
end
|
89
95
|
|
96
|
+
def image_uri(item_id)
|
97
|
+
"#{BASE_URI}/#{item_id}/image#{config_uri}"
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_image_link(item)
|
101
|
+
item[:image_link] = unless item[:image_name].empty?
|
102
|
+
image_uri(item[:item_id])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def items_add_image_link(items)
|
107
|
+
items.map do |item|
|
108
|
+
add_image_link(item) if item
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def return_items_with_image_link(uri)
|
113
|
+
result = request_item('get', uri)
|
114
|
+
items_add_image_link(result[:items]) if result[:items]
|
115
|
+
|
116
|
+
result
|
117
|
+
end
|
118
|
+
|
90
119
|
def request_item(method, uri, params = {})
|
91
120
|
response = HTTParty.send(method, uri, params)
|
92
121
|
JSON.parse(response.body).with_indifferent_access
|
data/lib/zoho/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoho_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Ofilada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,8 @@ files:
|
|
84
84
|
- bin/console
|
85
85
|
- bin/setup
|
86
86
|
- docs/README.md
|
87
|
+
- docs/inventory/README.md
|
88
|
+
- docs/inventory/items.md
|
87
89
|
- lib/zoho.rb
|
88
90
|
- lib/zoho/configuration.rb
|
89
91
|
- lib/zoho/inventory/item.rb
|