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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/example.rb +3 -4
  3. data/lib/shippo.rb +9 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b70f8f58f5b9ba939df519f8843c57a600e8f1c
4
- data.tar.gz: ca1964b87ce5f092e4af8880cf9c5568b0598297
3
+ metadata.gz: 5e21d3ec29ed56a00fd431e11a2fbef68a7da0e5
4
+ data.tar.gz: fbb6171b9cd52c4c9f60309dc49a47d90333464b
5
5
  SHA512:
6
- metadata.gz: 69cab04b54f2063bdd876d9b11d0ae41a90094f54a08d697c92c29d54c52f0aff692216397786bd3e32dd4776d3eb4bdcb11d26942764697498f3518f6dd39b7
7
- data.tar.gz: 48ee7d5df7a153fc00136ae19a5e6173b6c50eeab1a7a5900fbf5ab3188a61c7bee4a07ebe0d15c349a0ac6e415810b95bbdadac0a414f2e0bf2692b0ce8343c
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 <USERNAME> and <PASSWORD> with your credentials
8
- Shippo::api_user = '<USERNAME>'
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
- @api_user = ''
25
- @api_pass = ''
24
+ @api_token = ''
26
25
 
27
26
  class << self
28
- attr_accessor :api_base, :api_version, :api_user, :api_pass
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
- unless @api_user && @api_pass
37
- raise AuthError.new("API credentials missing! Make sure to set Shippo.api_user, Shippo.api_Pass")
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!(:accept => :json, :content_type => :json)
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 = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shippo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shippo & Contributors