shippo 1.0.2 → 1.0.3
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/example.rb +3 -4
- data/lib/shippo.rb +9 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e21d3ec29ed56a00fd431e11a2fbef68a7da0e5
|
4
|
+
data.tar.gz: fbb6171b9cd52c4c9f60309dc49a47d90333464b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f4d4462aed8cdd311635af1c1a6bdb854937b12e8fbd391908dedb2737802c17c7a7f67222264621f1772862fecc22baeacb7c775f25b1569feb83c0f34928
|
7
|
+
data.tar.gz: 1c198688269bb9c5c568828bf6e2b8d4e141f6020429bf5acbc0899c95aca1fe2e65450936a649b3fb996711d8fe80391ef13c276aff0747e20622621b368a11
|
data/example.rb
CHANGED
@@ -4,9 +4,8 @@
|
|
4
4
|
require 'shippo'
|
5
5
|
require 'timeout'
|
6
6
|
|
7
|
-
# replace <
|
8
|
-
Shippo::
|
9
|
-
Shippo::api_pass = '<PASSWORD>'
|
7
|
+
# replace <YOU_PRIVATE_KEY> with your ShippoToken key
|
8
|
+
Shippo::api_token = 'YOU_PRIVATE_KEY'
|
10
9
|
|
11
10
|
# Create address_from object
|
12
11
|
address_from = {
|
@@ -115,4 +114,4 @@ if transaction.object_status == "SUCCESS"
|
|
115
114
|
else
|
116
115
|
puts "Error generating label:"
|
117
116
|
puts transaction.messages
|
118
|
-
end
|
117
|
+
end
|
data/lib/shippo.rb
CHANGED
@@ -21,11 +21,10 @@ require_relative 'shippo/refund.rb'
|
|
21
21
|
module Shippo
|
22
22
|
@api_base = 'https://api.goshippo.com/v1'
|
23
23
|
@api_version = 1.0
|
24
|
-
@
|
25
|
-
@api_pass = ''
|
24
|
+
@api_token = ''
|
26
25
|
|
27
26
|
class << self
|
28
|
-
attr_accessor :api_base, :api_version, :
|
27
|
+
attr_accessor :api_base, :api_version, :api_token
|
29
28
|
end
|
30
29
|
|
31
30
|
def self.api_url(url='')
|
@@ -33,13 +32,17 @@ module Shippo
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def self.request(method, url, params = {}, headers = {})
|
36
|
-
|
37
|
-
raise AuthError.new("API credentials missing! Make sure to set Shippo.
|
35
|
+
if @api_token.empty?
|
36
|
+
raise AuthError.new("API credentials missing! Make sure to set Shippo.api_token")
|
38
37
|
end
|
39
38
|
begin
|
40
39
|
payload = {}
|
41
40
|
url = api_url(url)
|
42
|
-
headers.merge!(
|
41
|
+
headers.merge!(
|
42
|
+
:accept => :json,
|
43
|
+
:content_type => :json,
|
44
|
+
:Authorization => "ShippoToken #{@api_token}"
|
45
|
+
)
|
43
46
|
case method
|
44
47
|
when :get
|
45
48
|
pairs = []
|