ruby-etsy 0.0.1 → 0.0.2
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/lib/ruby-etsy/calls/receipts.rb +2 -2
- data/lib/ruby-etsy/client.rb +11 -6
- data/lib/ruby-etsy/version.rb +1 -1
- 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: aacff473114220017a6ad466b7764c70f28b50b2f32e7fa242778dc5812eb036
|
4
|
+
data.tar.gz: 600c32130456c4dbeb82bcabfe86cd20592ff62f2afd426fe28960404a629004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f893cecd3531bbbf5f13c37b8a84bbc0eb4aed8aff52dcee34ad2df56280b0d9795c9062498faf2fb8ea274a2d1f4339a003d796f8e6c3a2550acd836a574f0a
|
7
|
+
data.tar.gz: da077e8ca197f2a1428689a843d75a07bb93d756349d9d54b71ad1e1a8eb33f31b4e6ba03e6df12954234e93eecf89fc7ae0b5cd05c9269d28efd825b76f7233
|
@@ -2,8 +2,8 @@ class RubyEtsy
|
|
2
2
|
module Calls
|
3
3
|
module Receipts
|
4
4
|
|
5
|
-
def get_receipts
|
6
|
-
client.action("/shops/#{client.shop_id}/receipts", http_method: :get)
|
5
|
+
def get_receipts(query_params={})
|
6
|
+
client.action("/shops/#{client.shop_id}/receipts", http_method: :get, query_params: query_params)
|
7
7
|
end
|
8
8
|
|
9
9
|
def get_receipt(id)
|
data/lib/ruby-etsy/client.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'json'
|
3
3
|
require 'http-parser'
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/core_ext'
|
4
6
|
|
5
7
|
class RubyEtsy
|
6
8
|
class Client
|
7
9
|
|
8
10
|
REFRESH_TOKEN_URL='https://api.etsy.com/v3/public/oauth/token'
|
9
11
|
V3_URL='https://openapi.etsy.com/v3/application'
|
10
|
-
|
12
|
+
|
11
13
|
attr_accessor :access_token, :refresh_token, :api_key, :api_secret, :shop_id
|
12
14
|
|
13
15
|
def initialize(access_token:, refresh_token:, api_key:, api_secret:, shop_id:)
|
@@ -20,16 +22,16 @@ class RubyEtsy
|
|
20
22
|
@shop_id = shop_id || RubyEtsy.config.shop_id
|
21
23
|
end
|
22
24
|
|
23
|
-
def action(url, payload: {}, http_method: :post)
|
25
|
+
def action(url, payload: {}, query_params: {}, http_method: :post)
|
24
26
|
headers = {
|
25
27
|
'User-Agent': "RubyEtsy client v#{RubyEtsy::VERSION})",
|
26
28
|
'x-api-key': api_key,
|
27
29
|
'Authorization': "Bearer #{access_token}"
|
28
30
|
}
|
29
|
-
|
31
|
+
|
30
32
|
response = ::RestClient::Request.execute(
|
31
33
|
method: http_method,
|
32
|
-
url: construct_url(url),
|
34
|
+
url: construct_url(url, query_params),
|
33
35
|
payload: payload.to_json,
|
34
36
|
headers: headers,
|
35
37
|
timeout: 5,
|
@@ -64,13 +66,16 @@ class RubyEtsy
|
|
64
66
|
@access_token = parsed['access_token']
|
65
67
|
@refresh_token = parsed['refresh_token']
|
66
68
|
|
69
|
+
puts parsed
|
70
|
+
|
67
71
|
::HttpParser.parse(response)
|
68
72
|
end
|
69
73
|
|
70
74
|
private
|
71
75
|
|
72
|
-
def construct_url(url)
|
73
|
-
"
|
76
|
+
def construct_url(url, query_params={})
|
77
|
+
query = query_params.present? ? URI.encode_www_form(query_params).prepend('?') : ""
|
78
|
+
"#{V3_URL}#{url}#{query}"
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|
data/lib/ruby-etsy/version.rb
CHANGED