unleashed 0.1.14 → 0.1.15

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: 163e4108af74a8837955b70ece495fce05e57d754dea7456fe4728acf6cfe898
4
- data.tar.gz: 0a483a88892922a15831688c082dbc2e1b2f26b14263186ca39cb283064b9be3
3
+ metadata.gz: 463d518bf60dce8a899f4e616d0b2ae0ec2ac76555fd575cd0dfa192eb412224
4
+ data.tar.gz: 29778dc4c4361ab5eb12e99a455cc27ffa04b9fdbe1bd09f663956a2155ec1d6
5
5
  SHA512:
6
- metadata.gz: acbf6829e4329b7e330ccdbe6cea08fa4b2cc4c5d07d2c4cadbea1f3906a8edae529e1a92931eb1c0d98adabfc07efe2d52fb0eba8040b6b477db0d517b6c495
7
- data.tar.gz: cf3eb8666c697dc75739735ad1b00400eb564328dcfc54d8a0432236b9958c22ceef757a4dd66c0c7d50595cb9fbc3c123758c62dc50ecb46bab464f53453478
6
+ metadata.gz: '08a6480f14abac43480273813a643e37e109625e817cbf84bfcb830cc196714d05ffe68773ecf0abf24450146b4d43f60cebcd55dfd7e4a828a31c7ea4c54d6c'
7
+ data.tar.gz: 2294e7540617305b2caa36b061a9644a5b1fc36b8d345fb8a612615f1107d116184b3ac6509b7d6224b27ddfde0d9248fe808abaa5ccaf6f93492a352a625573
data/CHANGELOG.md CHANGED
@@ -2,10 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.15] - 2020-02-26
6
+
7
+ - Update and fix bugs for `client`, `currency`, `customer`, `invoice` resources.
8
+ - Show status code in error messge.
9
+ - Print request info to debug easier.
10
+
5
11
  ## [0.1.14] - 2020-02-23
6
12
 
7
13
  - Update options, queries, comments of `currencies`, `customers`, `invoices`, `payment terms`.
8
- - Replace `create` method by `create_or_update` method of `customers`
14
+ - Replace `create` method by `create_or_update` method of `customers`.
9
15
 
10
16
  ## [0.1.13] - 2019-12-05
11
17
 
@@ -60,6 +60,7 @@ module Unleashed
60
60
  request.headers['Content-Type'] = 'application/json'
61
61
  request.headers['api-auth-id'] = @api_id
62
62
  request.headers['api-auth-signature'] = signature(request.params.to_query)
63
+ request
63
64
  end
64
65
 
65
66
  # Make a HTTP GET request
@@ -73,12 +74,18 @@ module Unleashed
73
74
  request.params = parameters
74
75
 
75
76
  # Set headers
76
- init_default_headers(request)
77
+ request = init_default_headers(request)
77
78
 
78
79
  # Assign more custom headers
79
80
  headers.each do |key, value|
80
81
  request.headers[key] = value
81
82
  end
83
+
84
+ # Print log
85
+ time = Time.zone.now.strftime('%Y-%m-%d %H:%M:%S %z')
86
+ puts "[#{time}] Client -- : HEADERS #{request.headers}"
87
+ puts "[#{time}] Client -- : GET #{request.path}"
88
+ puts "[#{time}] Client -- : PARAMS #{request.params}"
82
89
  end
83
90
 
84
91
  on_complete(response) unless skip_status_check
@@ -103,6 +110,13 @@ module Unleashed
103
110
  end
104
111
 
105
112
  request.body = parameters.to_json
113
+
114
+ # Print log
115
+ time = Time.zone.now.strftime('%Y-%m-%d %H:%M:%S %z')
116
+ puts "[#{time}] Client -- : HEADERS #{request.headers}"
117
+ puts "[#{time}] Client -- : POST #{request.path}"
118
+ puts "[#{time}] Client -- : PARAMS #{request.params}"
119
+ puts "[#{time}] Client -- : BODY #{request.body}"
106
120
  end
107
121
 
108
122
  on_complete(response) unless skip_status_check
@@ -41,7 +41,7 @@ module Unleashed
41
41
  @response.body
42
42
  else
43
43
  json_response = JSON.parse(@response.body)
44
- message = ''
44
+ message = "[StatusCode=#{@response.status}] - "
45
45
  message << json_response['description'] if json_response.key?('description')
46
46
  message << json_response['Description'] if json_response.key?('Description')
47
47
 
@@ -13,7 +13,7 @@ module Unleashed
13
13
  # @return [Array<Unleashed::Currency>] List all currencies.
14
14
  def all
15
15
  endpoint = 'Currencies'
16
- response = JSON.parse(@client.get(endpoint, options).body)
16
+ response = JSON.parse(@client.get(endpoint).body)
17
17
  currencies = response.key?('Items') ? response['Items'] : []
18
18
  currencies.map { |attributes| Unleashed::Currency.new(@client, attributes) }
19
19
  end
@@ -37,7 +37,6 @@ module Unleashed
37
37
  # Handle Page option
38
38
  if params[:Page].present?
39
39
  endpoint << "/#{params[:Page]}"
40
- params.delete :Page
41
40
  end
42
41
 
43
42
  response = JSON.parse(@client.get(endpoint, params).body)
@@ -48,11 +47,11 @@ module Unleashed
48
47
  # Get a single customer
49
48
  # /Customers/E6E8163F-6911-40e9-B740-90E5A0A3A996 - returns details of a particular customer.
50
49
  #
51
- # @param id [String] customer ID.
50
+ # @param guid [String] customer ID.
52
51
  #
53
52
  # @return [Unleashed::Customer]
54
- def find(id)
55
- endpoint = "Customers/#{id}"
53
+ def find(guid)
54
+ endpoint = "Customers/#{guid}"
56
55
  response = JSON.parse(@client.get(endpoint).body)
57
56
  Unleashed::Customer.new(@client, response)
58
57
  end
@@ -68,7 +68,6 @@ module Unleashed
68
68
  # Handle Page option
69
69
  if params[:Page].present?
70
70
  endpoint << "/#{params[:Page]}"
71
- params.delete :Page
72
71
  end
73
72
 
74
73
  response = JSON.parse(@client.get(endpoint, params).body)
@@ -2,7 +2,7 @@ module Unleashed
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 14
5
+ TINY = 15
6
6
 
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}".freeze
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unleashed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nhan Nguyen