ruby-etsy 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby-etsy/client.rb +8 -2
- data/lib/ruby-etsy/version.rb +1 -1
- data/lib/ruby-etsy.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9660b0a445d0f3d1e2ecf62fc767583547b2402c2da00fdc57c508df6347036
|
4
|
+
data.tar.gz: e248592fdee4408b774b920f094be1e39a0d4932eaf910028ec167f345aca526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eb9f863c7ed6d4758eccb1564828e82cca6ce30c95926042b33dba968826a7f3770a075a031565507694d5bbc41d5a1da4c88510e2c9506af0a3f9cbea234aa
|
7
|
+
data.tar.gz: d11d0aa410c89e43f10b2e7e763cdf004927f78b14f787338da38d372e6a8911bc3589bb48722ceefbccc0960b77a13311c25e0ce917f1a3585e98772d856474
|
data/lib/ruby-etsy/client.rb
CHANGED
@@ -5,6 +5,8 @@ require 'active_support'
|
|
5
5
|
require 'active_support/core_ext'
|
6
6
|
|
7
7
|
class RubyEtsy
|
8
|
+
class RefreshTokenError < StandardError; end;
|
9
|
+
|
8
10
|
class Client
|
9
11
|
|
10
12
|
REFRESH_TOKEN_URL='https://api.etsy.com/v3/public/oauth/token'
|
@@ -42,8 +44,9 @@ class RubyEtsy
|
|
42
44
|
rescue RestClient::Unauthorized => e
|
43
45
|
puts "RESCUED UNATHORIZED"
|
44
46
|
|
45
|
-
refresh_token
|
46
|
-
|
47
|
+
token = send :refresh_token
|
48
|
+
|
49
|
+
raise RefreshTokenError.new('Could not refresh token') unless token.success?
|
47
50
|
end
|
48
51
|
|
49
52
|
def refresh_token
|
@@ -63,12 +66,15 @@ class RubyEtsy
|
|
63
66
|
)
|
64
67
|
|
65
68
|
parsed = JSON.parse(response.body)
|
69
|
+
|
66
70
|
@access_token = parsed['access_token']
|
67
71
|
@refresh_token = parsed['refresh_token']
|
68
72
|
|
69
73
|
puts parsed
|
70
74
|
|
71
75
|
::HttpParser.parse(response)
|
76
|
+
rescue RestClient::ExceptionWithResponse => e
|
77
|
+
::HttpParser.parse(OpenStruct.new(code: e.http_code, body: e.http_body))
|
72
78
|
end
|
73
79
|
|
74
80
|
private
|
data/lib/ruby-etsy/version.rb
CHANGED
data/lib/ruby-etsy.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-etsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adem Dinarevic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.3.7
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Ruby client for Etsy API
|