seoshop-api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjZhOTBlZmI0MDBjMWQwNjRmZjE0MjlmZGQ2NmFlOWM1YThjMzVmNA==
4
+ ZGQwMzc5YzYzMGJiYTRjYjBlOTliMGYyNTQwMzI2NjFkN2Y2OGZlNA==
5
5
  data.tar.gz: !binary |-
6
- NmM4YTNhMTc5M2Y0MTQ1MTk2ZWFlNmNhODc2NGI2ZDUxOGQ5YjE0Ng==
6
+ NGY2NWVkNDNkNDZjOTZiNTZhM2NjZjY2ZjY1ZmFkNjc4MzFiMmZlOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWQwZjA3NzA3YzBmNjI2MGE2NThlOWI2NWZjYmI5NzU2NDdkZTdjMWIzZGJi
10
- ZjYzYWFjYmI2YjIxMmI3NDAwNDkwMWRkMjNhYzdjNWJkNGE3ZjJmMmQxYmVh
11
- ZGNlNWRlNjE4YTkzNmFjODMyZjBkNDY5NWUyZWRjMzMzOWFkYTI=
9
+ MWFkMDYyYjQxYWY2YzkwMWFiZTNiMzY5MTNmZGFkNTI0MzkwODc0YTI0YTc4
10
+ N2I5ZTRhZmUyZDFhYWYwNDY1Mjk2ZjllMzAwZDNiMzcwMTM1MjMwMzk4ZDA4
11
+ ZTYxZDUxODhjMmIzNmJkZDUzZTY3ZTE5ZTQ0Y2I4MGQyMmU5YmE=
12
12
  data.tar.gz: !binary |-
13
- NzVmNmY1ZGEyNTMxZmUwMzg5ZjNmOTk2MWJiMGIwN2Y5MmVlZDc1MTRhOGYw
14
- MTc1MmIzN2I0ZTcxMTU5YjE2YWZiMzRiNzkyOTFjYjQ3YzJhMWY3MTQyZTQ5
15
- M2U0MjYwODgwMzM2NzBhOWQ0MjY0ZDFkOGViOWIzNDdkNDM3OGQ=
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
- Use Client:
30
+ Create a client, and use it to call the SEOshop api.
31
31
 
32
32
  ```ruby
33
33
 
34
- shop_api = Seoshop.client('shop_token', 'shop_language')
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,7 +1,8 @@
1
1
  module Seoshop
2
2
  module Account
3
3
  def get_rate_limit
4
- get("#{@shop_language}/account/ratelimit.json")['accountRatelimit']
4
+ response = get("#{@shop_language}/account/ratelimit.json")
5
+ response.body ? response.body['accountRatelimit'] : false
5
6
  end
6
7
  end
7
8
  end
@@ -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)['customers']
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")['count']
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")['customer']
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)['orders']
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")['count']
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")['order']
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")['order_products']
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)['products']
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")['count']
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")['product']
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
@@ -1,15 +1,18 @@
1
1
  module Seoshop
2
2
  module Shop
3
3
  def get_shop
4
- get("#{@shop_language}/shop.json")['shop']
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")['shop_website']
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")['shop_company']
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
@@ -42,7 +42,7 @@ module Seoshop
42
42
  def get(url, params = {})
43
43
  params = params.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}
44
44
  preform(url, :get, params: params) do
45
- return connection.get(url, params).body
45
+ return connection.get(url, params)
46
46
  end
47
47
  end
48
48
 
@@ -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::HTTPUnauthorized < Exception
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
 
@@ -1,3 +1,3 @@
1
1
  module Seoshop
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler