seoshop-api 0.0.4 → 0.0.5
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 -10
- data/lib/seoshop-api.rb +2 -13
- data/lib/seoshop-api/client.rb +26 -4
- data/lib/seoshop-api/version.rb +1 -1
- data/seoshop-api.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0905bbaa91678c04a25d2480c99f05fc3a31029d
|
4
|
+
data.tar.gz: 6c69439808f4fef6efeb163ce7dc82575e0353eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b8939bb3ae94905e4aa035fe362a14710778cc1b1798d7740b542e34652103b200933c5cb9bd9f60dc0cb1df25f1d410350e16daae83486f4d82c5a26cf68e
|
7
|
+
data.tar.gz: b02279a2057f41d8797830bf3b5c4833607404d0d45cf87a44377e606ae2b6837d5a06143b97aa1fba5831e699ebd8a86755949c10282ec4d07d16a13be837cb
|
data/README.md
CHANGED
@@ -18,20 +18,11 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Configure:
|
22
|
-
```ruby
|
23
|
-
|
24
|
-
Seoshop.configure do |conf|
|
25
|
-
conf.app_key = 'app_key'
|
26
|
-
conf.secret = 'secret'
|
27
|
-
end
|
28
|
-
```
|
29
|
-
|
30
21
|
Create a client, and use it to call the SEOshop api.
|
31
22
|
|
32
23
|
```ruby
|
33
24
|
|
34
|
-
shop_api = Seoshop::Client.new('shop_token', 'shop_language')
|
25
|
+
shop_api = Seoshop::Client.new('api_key', 'api_secret', 'shop_token', 'shop_language', 'cluster_id')
|
35
26
|
|
36
27
|
shop_api.get_shop
|
37
28
|
|
data/lib/seoshop-api.rb
CHANGED
@@ -3,22 +3,11 @@ require 'seoshop-api/client'
|
|
3
3
|
|
4
4
|
module Seoshop
|
5
5
|
class << self
|
6
|
-
# @!attribute url
|
7
|
-
# @return [String] the base url of the Seoshop Api
|
8
|
-
attr_accessor :url
|
9
6
|
|
10
7
|
# @!attribute parallel_requests
|
11
8
|
# @return [Integer String] defines the maximum parallel request for the gem to preform
|
12
9
|
attr_accessor :parallel_requests
|
13
10
|
|
14
|
-
# @!attribute app_key
|
15
|
-
# @return [String] the app key that is registered with Storenvy
|
16
|
-
attr_accessor :app_key
|
17
|
-
|
18
|
-
# @!attribute secret
|
19
|
-
# @return [String] the secret that is registered with Storenvy
|
20
|
-
attr_accessor :secret
|
21
|
-
|
22
11
|
# Configuration interface of the gem
|
23
12
|
#
|
24
13
|
# @yield [self] to accept configuration settings
|
@@ -39,8 +28,8 @@ module Seoshop
|
|
39
28
|
#
|
40
29
|
# @return an instance of Seoshop::Client
|
41
30
|
#
|
42
|
-
def client(access_token, shop_language)
|
43
|
-
@client ||= Seoshop::Client.new(access_token, shop_language)
|
31
|
+
def client(api_key, api_secret, access_token, shop_language, cluster_id = 'eu1')
|
32
|
+
@client ||= Seoshop::Client.new(api_key, api_secret, access_token, shop_language, cluster_id)
|
44
33
|
end
|
45
34
|
|
46
35
|
private
|
data/lib/seoshop-api/client.rb
CHANGED
@@ -27,21 +27,43 @@ module Seoshop
|
|
27
27
|
include Seoshop::Account
|
28
28
|
include Seoshop::Brand
|
29
29
|
|
30
|
+
attr_accessor :api_key
|
31
|
+
attr_accessor :api_secret
|
30
32
|
attr_accessor :access_token
|
31
33
|
attr_accessor :shop_language
|
32
34
|
|
35
|
+
SERVER_EU1_LIVE = 'https://api.webshopapp.com/'
|
36
|
+
SERVER_US1_LIVE = 'https://api.shoplightspeed.com/'
|
37
|
+
|
33
38
|
#
|
34
39
|
# Creates a new instance of Seoshop::Client
|
35
40
|
#
|
36
|
-
# @param
|
41
|
+
# @param api_key [String] The App api key
|
42
|
+
# @param api_secret [String] The App secret
|
43
|
+
# @param access_token [String] The shop access token
|
44
|
+
# @param shop_language [String] The shop language
|
45
|
+
# @param cluster_id [String] The shop cluster id
|
37
46
|
# @param parallel_requests [Integer String] The maximum parallel request to do (5)
|
38
|
-
def initialize(access_token, shop_language,
|
47
|
+
def initialize(api_key, api_secret, access_token, shop_language, cluster_id = 'eu1', parallel_requests = 5)
|
48
|
+
@api_key = api_key
|
49
|
+
@api_secret = api_secret
|
39
50
|
@access_token = access_token
|
40
51
|
@shop_language = shop_language
|
41
|
-
@url =
|
52
|
+
@url = get_url(cluster_id)
|
42
53
|
@parallel_requests = parallel_requests
|
43
54
|
end
|
44
55
|
|
56
|
+
def get_url(cluster_id)
|
57
|
+
case cluster_id
|
58
|
+
when 'eu1'
|
59
|
+
SERVER_EU1_LIVE
|
60
|
+
when 'us1'
|
61
|
+
SERVER_US1_LIVE
|
62
|
+
else
|
63
|
+
SERVER_EU1_LIVE
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
45
67
|
#
|
46
68
|
# Does a GET request to the url with the params
|
47
69
|
#
|
@@ -125,7 +147,7 @@ module Seoshop
|
|
125
147
|
def connection
|
126
148
|
@connection ||= Faraday.new(url: @url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: @parallel_requests), headers: {:seoshop_api_connector => 'Ruby'+ Seoshop::VERSION}) do |conn|
|
127
149
|
|
128
|
-
conn.basic_auth(
|
150
|
+
conn.basic_auth(@api_key, Digest::MD5.hexdigest(@access_token + @api_secret))
|
129
151
|
|
130
152
|
conn.use Seoshop::ResponseParser
|
131
153
|
|
data/lib/seoshop-api/version.rb
CHANGED
data/seoshop-api.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'oauth2'
|
25
25
|
spec.add_dependency 'faraday'
|
26
26
|
spec.add_dependency 'typhoeus'
|
27
|
-
spec.add_dependency 'faraday_middleware', '0.9.0'
|
27
|
+
spec.add_dependency 'faraday_middleware', '~> 0.9.0'
|
28
28
|
spec.add_dependency 'rash'
|
29
29
|
spec.add_dependency 'oj'
|
30
30
|
spec.add_dependency 'activesupport'
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nimrod Popper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: faraday_middleware
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.9.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.9.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: Ruby wrapper for SEOshop API - written by Yotpo
|