shoptet 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoptet.rb +36 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8facc56cfe2afc649cbad1f5094830d94d83f1f8d3d564e8886f17efe1b5bc87
|
4
|
+
data.tar.gz: 82c8517d218cc6182c54620e1161428d992a43e70364c23438fb0970bf303a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ff366765e02c7fe423368d0afa62bda693811c96f4f681b490161274228d39e0713cca821d4d49768c17e5f7de51e80a291bad2473e5087ff3bf4f22ccf872b
|
7
|
+
data.tar.gz: c74cda5f867dd363950b031cd4995fdf9585b843e8f66b11bdd7ec4f5e8e3f728e8340d7cebf796756133b05b3b3678716994692a46b169454e680b8a357f516
|
data/lib/shoptet.rb
CHANGED
@@ -11,7 +11,7 @@ class Shoptet
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.version
|
14
|
-
'0.0.
|
14
|
+
'0.0.7'
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.ar_on_token_error(model)
|
@@ -31,9 +31,9 @@ class Shoptet
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.install
|
34
|
+
def self.install url, redirect_url, client_id, client_secret, code
|
35
35
|
data = {
|
36
|
-
'redirect_uri' =>
|
36
|
+
'redirect_uri' => redirect_url,
|
37
37
|
'client_id' => client_id,
|
38
38
|
'client_secret' => client_secret,
|
39
39
|
'code' => code,
|
@@ -41,19 +41,49 @@ class Shoptet
|
|
41
41
|
'scope' => 'api'
|
42
42
|
}
|
43
43
|
|
44
|
-
Shoptet::Request.post
|
44
|
+
Shoptet::Request.post url, data
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.login_token url, code, client_id, client_secret, redirect_url
|
48
|
+
data = {
|
49
|
+
code: code,
|
50
|
+
grant_type: 'authorization_code',
|
51
|
+
client_id: client_id,
|
52
|
+
client_secret: client_secret,
|
53
|
+
redirect_uri: redirect_url,
|
54
|
+
scope: 'basic_eshop'
|
55
|
+
}
|
56
|
+
|
57
|
+
Shoptet::Request.post url, data
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.basic_eshop url, access_token
|
61
|
+
Shoptet::Request.get url, { 'Authorization' => "Bearer #{access_token}" }
|
45
62
|
end
|
46
63
|
|
47
64
|
attr_accessor :api_token
|
48
65
|
|
49
|
-
def initialize
|
66
|
+
def initialize oauth_url:, oauth_token:, shop_url:, client_id:, api_token: nil, on_token_error: nil
|
50
67
|
@oauth_url = oauth_url
|
51
68
|
@oauth_token = oauth_token
|
69
|
+
@shop_url = shop_url
|
70
|
+
@client_id = client_id
|
52
71
|
@api_token = api_token
|
53
72
|
@on_token_error = on_token_error || DEFAULT_ON_TOKEN_ERROR
|
54
73
|
end
|
55
74
|
|
56
|
-
|
75
|
+
def authorize_url redirect_url, state
|
76
|
+
query = {
|
77
|
+
client_id: @client_id,
|
78
|
+
state: state,
|
79
|
+
scope: 'basic_eshop',
|
80
|
+
response_type: 'code',
|
81
|
+
redirect_uri: redirect_url
|
82
|
+
}.to_query
|
83
|
+
|
84
|
+
URI("#{@shop_url}action/OAuthServer/authorize?#{query}").to_s
|
85
|
+
end
|
86
|
+
|
57
87
|
def shop_info api_params = {}
|
58
88
|
result = request 'https://api.myshoptet.com/api/eshop'
|
59
89
|
result['data']
|