shippo 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e9b3dad7e28707246b571507602d3ba35099f2e
4
- data.tar.gz: 9cb5e1856dfc29c5b422af3329f41c85206a1aa8
3
+ metadata.gz: 61372142180e7a1c28f2b3153ecf2e164f17750d
4
+ data.tar.gz: 288cd677e69cb653cd1fef7f613238d7460bf647
5
5
  SHA512:
6
- metadata.gz: d42eeb2c390da517adf5b2fbd7303cd9a93b2404d8109e8b86048a797418e35a3bc06e4379f365c20e4eaa04aade647095141cbc7b14738b76935c8091e2e8aa
7
- data.tar.gz: 2b3ac47863a604ed0cfd4766893262b145fe2ec57ff9406f6b995891ba363d9a20fc2facbbc983436da10c968109ebd5693639d8160930bdc0505f078137b0de
6
+ metadata.gz: 686fff2de127307d1d1f4beb9f4f7ad479b824c44fe4fa0b8c35982d28c47266ef795cac646ec1ec5a0f0bb58997cb3536c87cd09a24ef7d53f3035e8d4689bb
7
+ data.tar.gz: 7deb3a6c77c6b0faba3f6639b4e1acc8b11efd334aacf4303a14ca9b2fc9a708152ebc29c5685d3f7b6f29ca5874aee04e37060d03500a1ef6808935eebf1beb
@@ -1,3 +1,9 @@
1
+ #### 3.1.0 release, Sep 11th, 2017
2
+ - Removed deprecated methods
3
+ - Removed hash payload in GET
4
+ - Made RestClient timeouts configurable
5
+ - Suppressed Hashie warnings
6
+
1
7
  #### 3.0.1 release, Jul 14th, 2017
2
8
  - Updated rest client dependency
3
9
 
@@ -11,14 +11,16 @@ require 'shippo/api/resource'
11
11
 
12
12
  module Shippo
13
13
  module API
14
- @base = 'https://api.goshippo.com'
15
- @version = ''
16
- @token = ''
17
- @debug = Integer(ENV['SHIPPO_DEBUG'] || 0) > 0 ? true : false
18
- @warnings = true
14
+ @base = 'https://api.goshippo.com'
15
+ @version = ''
16
+ @token = ''
17
+ @debug = Integer(ENV['SHIPPO_DEBUG'] || 0) > 0 ? true : false
18
+ @warnings = true
19
+ @open_timeout = 15
20
+ @read_timeout = 30
19
21
 
20
22
  class << self
21
- attr_accessor :base, :version, :token, :debug, :warnings
23
+ attr_accessor :base, :version, :token, :debug, :warnings, :open_timeout, :read_timeout
22
24
  # @param [Symbol] method One of :get, :put, :post
23
25
  # @param [String] uri the URL component after the first slash but before params
24
26
  # @param [Hash] params hash of optional parameters to add to the URL
@@ -0,0 +1,11 @@
1
+ require 'hashie/mash'
2
+ require 'hashie/extensions/stringify_keys'
3
+
4
+ module Shippo
5
+ module API
6
+ class ApiHash < Hashie::Mash
7
+ include Hashie::Extensions::StringifyKeys
8
+ disable_warnings
9
+ end
10
+ end
11
+ end
@@ -89,7 +89,7 @@ module Shippo
89
89
  private
90
90
 
91
91
  def shippo_phone_home
92
- payload = {}
92
+ payload = nil
93
93
  request_url = url
94
94
  (method == :get) ? request_url = params_to_url(params, url) : payload = params.to_json
95
95
  setup_headers!(headers)
@@ -118,8 +118,8 @@ module Shippo
118
118
  :method => method,
119
119
  :payload => payload,
120
120
  :url => url,
121
- :open_timeout => 15,
122
- :timeout => 30,
121
+ :open_timeout => ::Shippo::API.open_timeout,
122
+ :timeout => ::Shippo::API.read_timeout,
123
123
  :user => username,
124
124
  :password => password,
125
125
  :user_agent => 'Shippo/v2.0 RubyBindings'
@@ -1,10 +1,10 @@
1
1
  require 'forwardable'
2
2
 
3
- require 'hashie/mash'
4
3
  require 'active_support/inflector'
5
4
 
6
5
  require 'shippo/exceptions'
7
6
 
7
+ require_relative 'api_hash'
8
8
  require_relative 'api_object'
9
9
  require_relative 'category/status'
10
10
  require_relative 'transformers/list'
@@ -14,19 +14,11 @@ require_relative 'extend/url'
14
14
 
15
15
  module Shippo
16
16
  module API
17
- class Resource < Hashie::Mash
18
- include Hashie::Extensions::StringifyKeys
17
+ class Resource < ApiHash
19
18
  include Enumerable
20
19
  extend Forwardable
21
20
 
22
- disable_warnings
23
-
24
- def self.object_properties
25
- Shippo::API::ApiObject::PROPS
26
- end
27
-
28
21
  attr_accessor :object
29
- def_delegators :@object, *object_properties
30
22
 
31
23
  # Creates a possibly recursive chain (map of lists, etc) of Resource
32
24
  # instances based on whether each value is a scalar, array or a hash.
@@ -45,15 +37,6 @@ module Shippo
45
37
  name.split('::')[-1]
46
38
  end
47
39
 
48
- # Generate object_ accessors.
49
- object_properties.each do |property|
50
- method_name = ApiObject.field_name(property)
51
- define_method method_name do
52
- STDOUT.puts "#{method_name} style accessors are deprecated in favor of #resource.object.#{property}" if Shippo::API.warnings
53
- self.object.send(property)
54
- end
55
- end
56
-
57
40
  # allows resources to use default or a custom url
58
41
  include Shippo::API::Extend::Url
59
42
  # allows resources to set supported operations
@@ -68,7 +51,7 @@ module Shippo
68
51
  (args.first.is_a?(String) && args.first =~ /^[0-9A-Fa-f]+$/)
69
52
  self.id = args.first
70
53
  elsif args.first.respond_to?(:keys)
71
- h = Hashie::Mash.new(args.first)
54
+ h = ApiHash.new(args.first)
72
55
  self.deep_merge!(h)
73
56
  self.object = ApiObject.create_object(self)
74
57
  transformers.each do |transformer|
@@ -1,5 +1,5 @@
1
1
  module Shippo
2
2
  module API
3
- VERSION = '3.0.1'
3
+ VERSION = '3.1.0'
4
4
  end
5
5
  end
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: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shippo & Contributors
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-14 00:00:00.000000000 Z
12
+ date: 2017-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -236,6 +236,7 @@ files:
236
236
  - bin/track_example
237
237
  - lib/shippo.rb
238
238
  - lib/shippo/api.rb
239
+ - lib/shippo/api/api_hash.rb
239
240
  - lib/shippo/api/api_object.rb
240
241
  - lib/shippo/api/category.rb
241
242
  - lib/shippo/api/category/base.rb