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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5c1119506f213182d14a2ad038226dd479d2a8b7bae80c550d27bbc2163b4d4
4
- data.tar.gz: 8aaad4438e7466c828e1b45b1e96dac5866f0626bd5586c9250eece41a22b502
3
+ metadata.gz: aacff473114220017a6ad466b7764c70f28b50b2f32e7fa242778dc5812eb036
4
+ data.tar.gz: 600c32130456c4dbeb82bcabfe86cd20592ff62f2afd426fe28960404a629004
5
5
  SHA512:
6
- metadata.gz: 3bd25b9a3d23ba7aab5244556d63e032f2c8e5e9d37b37945e730878b3afd39d263bd4841b2bdceb81a2d0407726813c167cc9820976342765a86bfa255f4ce9
7
- data.tar.gz: dc0025d447c0bca6dab1efd383271d1f06372ab9460ff5921c0ec852b1c71612b0bd230b6d04a2abc7f279089a8085df74cc9b7c69e65c86bd3e6c440444522d
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)
@@ -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
- "#{V3_URL}#{url}"
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
@@ -1,3 +1,3 @@
1
1
  class RubyEtsy
2
- VERSION="0.0.1"
2
+ VERSION="0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-etsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adem Dinarevic