seoshop-api 0.0.2 → 0.0.3
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 +8 -8
- data/README.md +5 -2
- data/lib/seoshop-api/api/account.rb +2 -1
- data/lib/seoshop-api/api/customer.rb +6 -3
- data/lib/seoshop-api/api/order.rb +8 -4
- data/lib/seoshop-api/api/product.rb +6 -3
- data/lib/seoshop-api/api/shop.rb +6 -3
- data/lib/seoshop-api/client.rb +1 -1
- data/lib/seoshop-api/core/response_parser.rb +12 -2
- data/lib/seoshop-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGQwMzc5YzYzMGJiYTRjYjBlOTliMGYyNTQwMzI2NjFkN2Y2OGZlNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGY2NWVkNDNkNDZjOTZiNTZhM2NjZjY2ZjY1ZmFkNjc4MzFiMmZlOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWFkMDYyYjQxYWY2YzkwMWFiZTNiMzY5MTNmZGFkNTI0MzkwODc0YTI0YTc4
|
10
|
+
N2I5ZTRhZmUyZDFhYWYwNDY1Mjk2ZjllMzAwZDNiMzcwMTM1MjMwMzk4ZDA4
|
11
|
+
ZTYxZDUxODhjMmIzNmJkZDUzZTY3ZTE5ZTQ0Y2I4MGQyMmU5YmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTM3NWUwOGYyNzU1ZmJhYWM3NTY4YzM1NTA4M2EzNDAyMTc4ZjA5Yjg4MGFh
|
14
|
+
N2ZkY2U3YTQ5YzhmNWUxMzBmYWJlMDQ2OTgzY2E5ZGM4N2ZlYWVjZjE1Njhl
|
15
|
+
Y2VmNDcxMDU0ZDQwYmEwOGQxMzlkOWZjNmE0MWUzZTAwMzYxMjE=
|
data/README.md
CHANGED
@@ -27,13 +27,16 @@ Seoshop.configure do |conf|
|
|
27
27
|
end
|
28
28
|
```
|
29
29
|
|
30
|
-
|
30
|
+
Create a client, and use it to call the SEOshop api.
|
31
31
|
|
32
32
|
```ruby
|
33
33
|
|
34
|
-
shop_api = Seoshop.
|
34
|
+
shop_api = Seoshop::Client.new('shop_token', 'shop_language')
|
35
35
|
|
36
36
|
shop_api.get_shop
|
37
|
+
|
38
|
+
shop_api.get_products
|
39
|
+
|
37
40
|
```
|
38
41
|
|
39
42
|
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module Seoshop
|
2
2
|
module Customer
|
3
3
|
def get_customers(params = {})
|
4
|
-
get("#{@shop_language}/customers.json", params)
|
4
|
+
response = get("#{@shop_language}/customers.json", params)
|
5
|
+
response.body ? response.body['customers'] : false
|
5
6
|
end
|
6
7
|
|
7
8
|
def get_customers_count
|
8
|
-
get("#{@shop_language}/customers/count.json")
|
9
|
+
response = get("#{@shop_language}/customers/count.json")
|
10
|
+
response.body ? response.body['count'] : false
|
9
11
|
end
|
10
12
|
|
11
13
|
def get_customer(customer_id)
|
12
|
-
get("#{@shop_language}/customers/#{customer_id}.json")
|
14
|
+
response = get("#{@shop_language}/customers/#{customer_id}.json")
|
15
|
+
response.body ? response.body['customer'] : false
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -1,19 +1,23 @@
|
|
1
1
|
module Seoshop
|
2
2
|
module Order
|
3
3
|
def get_orders(params = {})
|
4
|
-
get("#{@shop_language}/orders.json", params)
|
4
|
+
response = get("#{@shop_language}/orders.json", params)
|
5
|
+
response.body ? response.body['orders'] : false
|
5
6
|
end
|
6
7
|
|
7
8
|
def get_orders_count
|
8
|
-
get("#{@shop_language}/orders/count.json")
|
9
|
+
response = get("#{@shop_language}/orders/count.json")
|
10
|
+
response.body ? response.body['count'] : false
|
9
11
|
end
|
10
12
|
|
11
13
|
def get_order(order_id)
|
12
|
-
get("#{@shop_language}/orders/#{order_id}.json")
|
14
|
+
response = get("#{@shop_language}/orders/#{order_id}.json")
|
15
|
+
response.body ? response.body['order'] : false
|
13
16
|
end
|
14
17
|
|
15
18
|
def get_order_products(order_id)
|
16
|
-
get("#{@shop_language}/orders/#{order_id}/products.json")
|
19
|
+
response = get("#{@shop_language}/orders/#{order_id}/products.json")
|
20
|
+
response.body ? response.body['order_products'] : false
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module Seoshop
|
2
2
|
module Product
|
3
3
|
def get_products(params = {})
|
4
|
-
get("#{@shop_language}/products.json", params)
|
4
|
+
response = get("#{@shop_language}/products.json", params)
|
5
|
+
response.body ? response.body['products'] : false
|
5
6
|
end
|
6
7
|
|
7
8
|
def get_products_count
|
8
|
-
get("#{@shop_language}/products/count.json")
|
9
|
+
response = get("#{@shop_language}/products/count.json")
|
10
|
+
response.body ? response.body['count'] : false
|
9
11
|
end
|
10
12
|
|
11
13
|
def get_product(product_id)
|
12
|
-
get("#{@shop_language}/products/#{product_id}.json")
|
14
|
+
response = get("#{@shop_language}/products/#{product_id}.json")
|
15
|
+
response.body ? response.body['product'] : false
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
data/lib/seoshop-api/api/shop.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
module Seoshop
|
2
2
|
module Shop
|
3
3
|
def get_shop
|
4
|
-
get("#{@shop_language}/shop.json")
|
4
|
+
response = get("#{@shop_language}/shop.json")
|
5
|
+
response.body ? response.body['shop'] : false
|
5
6
|
end
|
6
7
|
|
7
8
|
def get_shop_website
|
8
|
-
get("#{@shop_language}/shop/website.json")
|
9
|
+
response = get("#{@shop_language}/shop/website.json")
|
10
|
+
response.body ? response.body['shop_website'] : false
|
9
11
|
end
|
10
12
|
|
11
13
|
def get_shop_company
|
12
|
-
get("#{@shop_language}/shop/company.json")
|
14
|
+
response = get("#{@shop_language}/shop/company.json")
|
15
|
+
response.body ? response.body['shop_company'] : false
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
data/lib/seoshop-api/client.rb
CHANGED
@@ -11,6 +11,15 @@ module Seoshop
|
|
11
11
|
body = env[:response].body.response || env[:response].body
|
12
12
|
elsif env[:status] == 401
|
13
13
|
raise Seoshop::ResponseParser::HTTPUnauthorized.new 'invalid Seoshop credentials'
|
14
|
+
elsif env[:status] == 404
|
15
|
+
raise Seoshop::ResponseParser::HTTPNotFound.new 'invalid Seoshop language'
|
16
|
+
elsif env[:status] == 429
|
17
|
+
rate_limits = env[:response_headers]['X-RateLimit-Remaining'].split('/')
|
18
|
+
rate_limits_reset = env[:response_headers]['X-RateLimit-Reset'].split('/')
|
19
|
+
seconds = rate_limits_reset[0] if rate_limits[0] == '-1'
|
20
|
+
seconds = rate_limits_reset[1] if rate_limits[1] == '-1'
|
21
|
+
seconds = rate_limits_reset[2] if rate_limits[2] == '-1'
|
22
|
+
raise Seoshop::ResponseParser::RateLimit.new "RateLimit reset in #{seconds} seconds"
|
14
23
|
elsif env[:response] && env[:response].body && env[:response].body.status
|
15
24
|
body = env[:response].body.status
|
16
25
|
end
|
@@ -83,8 +92,9 @@ module Seoshop
|
|
83
92
|
type
|
84
93
|
end
|
85
94
|
|
86
|
-
class Seoshop::ResponseParser::
|
87
|
-
end
|
95
|
+
class Seoshop::ResponseParser::RateLimit < Exception; end
|
96
|
+
class Seoshop::ResponseParser::HTTPUnauthorized < Exception; end
|
97
|
+
class Seoshop::ResponseParser::HTTPNotFound < Exception; end
|
88
98
|
end
|
89
99
|
end
|
90
100
|
|
data/lib/seoshop-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seoshop-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nimrod Popper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|