shipstation 0.16.5 → 0.16.6

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
  SHA1:
3
- metadata.gz: 240727bb719dd095c8286f787e325450c2f25be7
4
- data.tar.gz: f408f6b33e098c292eb9e9e3a6983873772c06d3
3
+ metadata.gz: a171fba8d97be21008ec2af692a5081c51e88761
4
+ data.tar.gz: 32deea3da2ddc28b4733d35877b15054aeaea1ab
5
5
  SHA512:
6
- metadata.gz: ff10333940a2c918ae056ec13f946e129efb635d81c6473d8a417aae7a884ee4c9a29eb344cd4c508713e0db6e030fea3f88d9f86a8f35cbc09be965f0288466
7
- data.tar.gz: ef89637da0992b4de87bd8ebbfb6d5a8e611a71a694cc1ee0dd2208894a256ec6d5c03102fdb8937815b272eda9d94fb98678bb35fd0a15cf6512d01d39a6327
6
+ metadata.gz: 76c794fceaab3966d0af00c080740d589e3e42fdfd646d551aef47c55da7be0bd2a6db905509addb7fb3c0ea300519326f40eb2cff3ce4769eac7b4201261609
7
+ data.tar.gz: ff74fc578bd9b07a1a3589d23f6be8351d61dccc0a5165d1123ff90c18afc80cf0003f001b42ca52dd3bab4c639a464107aee972276e31bf990beb7bb9876580
data/lib/shipstation.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rest-client'
2
4
 
3
5
  require 'shipstation/api_operations/list'
@@ -17,6 +19,7 @@ require 'shipstation/product'
17
19
  require 'shipstation/tag'
18
20
 
19
21
  module Shipstation
22
+
20
23
  API_BASE = "https://ssapi.shipstation.com/"
21
24
 
22
25
  class ShipstationError < StandardError
@@ -26,6 +29,15 @@ module Shipstation
26
29
  end
27
30
  class ConfigurationError < ShipstationError;
28
31
  end
32
+ class ApiRequestError < ShipstationError
33
+ attr_reader :response_code, :response_headers, :response_body
34
+
35
+ def initialize(response_code:, response_headers:, response_body:)
36
+ @response_code = response_code
37
+ @response_headers = response_headers
38
+ @response_body = response_body
39
+ end
40
+ end
29
41
 
30
42
  class << self
31
43
  def username
@@ -71,6 +83,13 @@ module Shipstation
71
83
  payload: payload ? payload.to_json : nil,
72
84
  headers: headers
73
85
  }).execute do |response, request, result|
86
+ if response.code != 200
87
+ raise ApiRequestError(
88
+ response_code: response.code,
89
+ response_headers: response.headers,
90
+ response_body: response.to_str
91
+ )
92
+ end
74
93
  str_response = response.to_str
75
94
  str_response.blank? ? '' : JSON.parse(str_response)
76
95
  end
@@ -1,3 +1,3 @@
1
1
  module Shipstation
2
- VERSION = "0.16.5"
2
+ VERSION = "0.16.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipstation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5
4
+ version: 0.16.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Dallimore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-30 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client