intelipost-rb 0.0.10 → 0.0.12

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: 9f75b4adac21fe2def1066be2374b9122a8fc704
4
- data.tar.gz: e8064d182a6f2b76e35acc234ddd4a321e11bf84
3
+ metadata.gz: b6506d54b108ddeb4a23050e92d9bb3d3406da6b
4
+ data.tar.gz: 3b41a657c7dc6ee52ccd42e993327f201684597e
5
5
  SHA512:
6
- metadata.gz: e9fe98aa914a191568d8681a3378c71f60f639c0714436f3fe4b8043c23c43c3179a56f84ff9849e4040c557533441c5d4a5f70575d38f1e16bf2696f0977906
7
- data.tar.gz: c5b94fb61a521a75be357b2d717137620c98e46074f9171ad4d4479a1d6553ae332e698d8b75646f1c6cc53a59ec69e4568b2c5a70c739a478e5478153685337
6
+ metadata.gz: 86ede30dd565ca866ddb1f9ce4a73b6cda3cfba6c28fb2c4dfcb20680d037e0ce4080540430718724d5a079b2921ea2e7873d97cb7bfe3d7e9a05da8f0f9fe64
7
+ data.tar.gz: 05432154d87a9072b09ec3cf1c53cdcd11f5ea43ae699b3e47e64f494437158e3323ee8f3f552bfaf18f98cf70c5fe5aa7ae775c67478095d3f28c712c0aaec9
data/.gitignore CHANGED
@@ -20,7 +20,6 @@
20
20
  /vendor/bundle
21
21
  /lib/bundler/man/
22
22
  .env
23
- spec/cassettes
24
23
 
25
24
  # gem
26
25
  Gemfile.lock
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
+ source 'https://rubygems.org'
3
4
  gemspec
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
8
  task :coverage do
7
9
  ENV['COVERAGE'] = 'true'
8
- Rake::Task["spec"].execute
10
+ Rake::Task['spec'].execute
9
11
  end
10
12
 
11
13
  task :console do
12
- sh "irb -rubygems -r intelipost-rb"
14
+ sh 'irb -rubygems -r intelipost-rb'
13
15
  end
14
16
 
15
- task :default => :spec
17
+ task default: :spec
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  # coding: utf-8
3
+
2
4
  lib = File.expand_path('../lib', __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'intelipost/version'
@@ -8,8 +10,8 @@ Gem::Specification.new do |spec|
8
10
  spec.version = Intelipost::VERSION
9
11
  spec.authors = ['Celestino Gomes', 'Luiz Rocha']
10
12
  spec.email = ['tinorj@gmail.com', 'lsdrocha@gmail.com']
11
- spec.description = %q{Gem to access the REST API of Intelipost}
12
- spec.summary = %q{Gem to access the REST API of Intelipost}
13
+ spec.description = %q(Gem to access the REST API of Intelipost)
14
+ spec.summary = %q(Gem to access the REST API of Intelipost)
13
15
  spec.homepage = 'http://github.com/gaveteiro/intelipost-rb'
14
16
  spec.license = 'MIT'
15
17
 
@@ -18,16 +20,16 @@ Gem::Specification.new do |spec|
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
21
  spec.require_paths = ['lib']
20
22
 
21
- spec.add_dependency 'faraday', '~> 0.11.0'
22
- spec.add_dependency 'faraday_middleware', '~> 0.11.0'
23
- spec.add_dependency 'hashie', '~> 3.4.1'
23
+ spec.add_dependency 'faraday', '>= 0.11', '< 1.0'
24
+ spec.add_dependency 'faraday_middleware', '>= 0.11', '< 1.0'
25
+ spec.add_dependency 'hashie', '>= 3.5', '< 3.6'
24
26
 
25
- spec.add_development_dependency 'bundler', '>= 1.7.6'
26
- spec.add_development_dependency 'rake', '~> 10.4.2'
27
- spec.add_development_dependency 'rspec', '~> 3.2.0'
28
- spec.add_development_dependency 'vcr', '~> 2.9.3'
29
- spec.add_development_dependency 'webmock', '~> 1.21'
27
+ spec.add_development_dependency 'bundler', '>= 1.7.6', '< 1.15'
28
+ spec.add_development_dependency 'rake', '~> 10.4', '>= 10.4.2'
29
+ spec.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
30
+ spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
31
+ spec.add_development_dependency 'dotenv', '~> 2.0', '>= 2.0.1'
32
+ spec.add_development_dependency 'webmock', '2.3.2'
30
33
  spec.add_development_dependency 'simplecov', '~> 0.10'
31
- spec.add_development_dependency 'dotenv', '~> 2.0.1'
32
34
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.7'
33
35
  end
@@ -1,16 +1,16 @@
1
- require "intelipost/mash"
1
+ require 'intelipost/mash'
2
2
 
3
3
  module Intelipost
4
4
  class Client
5
- HOST = "api.intelipost.com.br"
6
- SERVICE = "api/"
7
- API_VERSION = "v1"
5
+ HOST = 'api.intelipost.com.br'
6
+ SERVICE = 'api/'
7
+ API_VERSION = 'v1'
8
8
  attr_reader :uri, :options, :connection, :api_key, :platform
9
9
 
10
10
  def initialize(options)
11
11
  @options = { ssl: true }
12
12
  @options.merge! options
13
- uri = @options[:ssl] ? "https://" : "http://"
13
+ uri = @options[:ssl] ? 'https://' : 'http://'
14
14
  uri.concat HOST
15
15
 
16
16
  @uri = URI.join uri, SERVICE, API_VERSION
@@ -21,7 +21,7 @@ module Intelipost
21
21
  end
22
22
 
23
23
  def connection
24
- raise ArgumentError, "an api_key is required to connect" if api_key.nil?
24
+ raise ArgumentError, 'an api_key is required to connect' if api_key.nil?
25
25
 
26
26
  Faraday.new(url: @uri.to_s) do |conn|
27
27
  conn.request :json
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Intelipost
2
4
  class Mash < ::Hashie::Mash
5
+ disable_warnings if respond_to?(:disable_warnings)
6
+
3
7
  def success?
4
- self.has_key?('status') and self.status == 'OK'
8
+ key?('status') && status == 'OK'
5
9
  end
6
10
 
7
11
  def failure?
@@ -9,8 +13,16 @@ module Intelipost
9
13
  end
10
14
 
11
15
  def all_messages
12
- return unless self.has_key?('messages')
13
- self.messages.map(&:text).join(';')
16
+ return unless key?('messages')
17
+ messages.map(&:text).join(';')
18
+ end
19
+
20
+ def length
21
+ self[:length]
22
+ end
23
+
24
+ def key
25
+ self[:key]
14
26
  end
15
27
  end
16
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Intelipost
2
- VERSION = '0.0.10'
4
+ VERSION = '0.0.12'.freeze
3
5
  end
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.intelipost.com.br/api/v1/quote
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"origin_zip_code":"04037-003","destination_zip_code":"06396-200","volumes":[{"weight":0.1,"volume_type":"BOX","cost_of_goods":100,"width":10,"height":10,"length":10}],"additional_information":{"free_shipping":false,"extra_cost_absolute":0,"extra_cost_percentage":0,"lead_time_business_days":0,"sales_channel":"hotsite","client_type":"gold","delivery_method_ids":[1,2,3]}}'
9
+ headers:
10
+ platform:
11
+ - intelipost-gem-test
12
+ User-Agent:
13
+ - Faraday v0.12.1
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ date:
22
+ - Thu, 11 May 2017 00:23:20 GMT
23
+ content-type:
24
+ - application/json; charset=UTF-8
25
+ content-length:
26
+ - '1764'
27
+ connection:
28
+ - close
29
+ server:
30
+ - nginx/1.11.13
31
+ access-control-expose-headers:
32
+ - production
33
+ production:
34
+ - 'false'
35
+ access-control-allow-origin:
36
+ - "*"
37
+ access-control-allow-credentials:
38
+ - 'true'
39
+ access-control-allow-headers:
40
+ - origin, x-requested-with, content-type, api_key, token, production, display-errors,
41
+ api-key, platform, debug, ignore-all-conversion
42
+ access-control-allow-methods:
43
+ - PUT, GET, POST, DELETE, OPTIONS
44
+ x-server:
45
+ - nginx_spr-sae1-prod-application05
46
+ front-end-https:
47
+ - 'on'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"status":"OK","messages":[],"content":{"origin_zip_code":"4037003","destination_zip_code":"6396200","platform":"intelipost-gem-test","additional_information":{"extra_cost_absolute":0.0,"lead_time_business_days":0,"free_shipping":false,"delivery_method_ids":[1,2,3],"extra_cost_percentage":0.0,"tax_id":null,"client_type":"gold","sales_channel":"hotsite","payment_type":null,"is_state_tax_payer":null,"shipped_date":null,"calculate_estimated_date_exact":null},"identification":null,"quoting_mode":null,"id":1692119094,"client_id":8554,"created":1494462200077,"created_iso":"2017-05-10T21:23:20.077-03:00","delivery_options":[{"delivery_method_id":2,"delivery_estimate_business_days":8,"provider_shipping_cost":14.87,"final_shipping_cost":14.87,"description":"Correios
51
+ Sedex","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":0.167,"delivery_method_type":"EXPRESS","delivery_method_name":"Correios
52
+ Sedex","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false},{"delivery_method_id":1,"delivery_estimate_business_days":12,"provider_shipping_cost":16.45,"final_shipping_cost":16.45,"description":"Correios
53
+ PAC","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":0.167,"delivery_method_type":"STANDARD","delivery_method_name":"Correios
54
+ PAC","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false}],"volumes":[{"weight":0.1,"cost_of_goods":100.0,"width":10.0,"height":10.0,"length":10.0,"description":null,"sku_groups_ids":[],"product_category":null,"volume_type":"BOX"}],"cached":true},"time":"2.8
55
+ ms","timezone":"America/Sao_Paulo","locale":"pt_BR"}'
56
+ http_version:
57
+ recorded_at: Thu, 11 May 2017 00:23:20 GMT
58
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.intelipost.com.br/api/v1/quote
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"failure":"failure"}'
9
+ headers:
10
+ platform:
11
+ - intelipost-gem-test
12
+ User-Agent:
13
+ - Faraday v0.12.1
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 400
19
+ message:
20
+ headers:
21
+ date:
22
+ - Thu, 11 May 2017 00:23:20 GMT
23
+ content-type:
24
+ - application/json; charset=UTF-8
25
+ content-length:
26
+ - '359'
27
+ connection:
28
+ - close
29
+ server:
30
+ - nginx/1.11.13
31
+ access-control-expose-headers:
32
+ - production
33
+ production:
34
+ - 'false'
35
+ access-control-allow-origin:
36
+ - "*"
37
+ access-control-allow-credentials:
38
+ - 'true'
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: !binary |-
42
+ eyJzdGF0dXMiOiJFUlJPUiIsIm1lc3NhZ2VzIjpbeyJ0eXBlIjoiRVJST1Ii
43
+ LCJ0ZXh0IjoiRmFsdGFuZG8gaW5mb3JtYcOnw6NvIGRlIHZvbHVtZSIsImtl
44
+ eSI6InF1b3RlLnZvbHVtZXMubWlzc2luZyJ9LHsidHlwZSI6IkVSUk9SIiwi
45
+ dGV4dCI6IkZhbHRhbmRvIENFUCBkZSBkZXN0aW5vIiwia2V5IjoicXVvdGUu
46
+ ZGVzdGluYXRpb25aaXBDb2RlLm1pc3NpbmcifSx7InR5cGUiOiJFUlJPUiIs
47
+ InRleHQiOiJGYWx0YW5kbyBjZXAgZGUgb3JpZ2VtIiwia2V5IjoicXVvdGUu
48
+ b3JpZ2luWmlwQ29kZS5taXNzaW5nIn1dLCJ0aW1lIjoiMC4zIG1zIiwidGlt
49
+ ZXpvbmUiOiJBbWVyaWNhL1Nhb19QYXVsbyIsImxvY2FsZSI6InB0X0JSIn0=
50
+ http_version:
51
+ recorded_at: Thu, 11 May 2017 00:23:20 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,111 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.intelipost.com.br/api/v1/quote
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"origin_zip_code":"04037-003","destination_zip_code":"06396-200","volumes":[{"weight":0.1,"volume_type":"BOX","cost_of_goods":100,"width":10,"height":10,"length":10}],"additional_information":{"free_shipping":false,"extra_cost_absolute":0,"extra_cost_percentage":0,"lead_time_business_days":0,"sales_channel":"hotsite","client_type":"gold","delivery_method_ids":[1,2,3]}}'
9
+ headers:
10
+ platform:
11
+ - intelipost-gem-test
12
+ User-Agent:
13
+ - Faraday v0.12.1
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ date:
22
+ - Thu, 11 May 2017 00:23:19 GMT
23
+ content-type:
24
+ - application/json; charset=UTF-8
25
+ content-length:
26
+ - '1764'
27
+ connection:
28
+ - close
29
+ server:
30
+ - nginx/1.11.13
31
+ access-control-expose-headers:
32
+ - production
33
+ production:
34
+ - 'false'
35
+ access-control-allow-origin:
36
+ - "*"
37
+ access-control-allow-credentials:
38
+ - 'true'
39
+ access-control-allow-headers:
40
+ - origin, x-requested-with, content-type, api_key, token, production, display-errors,
41
+ api-key, platform, debug, ignore-all-conversion
42
+ access-control-allow-methods:
43
+ - PUT, GET, POST, DELETE, OPTIONS
44
+ x-server:
45
+ - nginx_spr-sae1-prod-application05
46
+ front-end-https:
47
+ - 'on'
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"status":"OK","messages":[],"content":{"origin_zip_code":"4037003","destination_zip_code":"6396200","platform":"intelipost-gem-test","additional_information":{"extra_cost_absolute":0.0,"lead_time_business_days":0,"free_shipping":false,"delivery_method_ids":[1,2,3],"extra_cost_percentage":0.0,"tax_id":null,"client_type":"gold","sales_channel":"hotsite","payment_type":null,"is_state_tax_payer":null,"shipped_date":null,"calculate_estimated_date_exact":null},"identification":null,"quoting_mode":null,"id":1692119094,"client_id":8554,"created":1494462199856,"created_iso":"2017-05-10T21:23:19.856-03:00","delivery_options":[{"delivery_method_id":2,"delivery_estimate_business_days":8,"provider_shipping_cost":14.87,"final_shipping_cost":14.87,"description":"Correios
51
+ Sedex","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":0.167,"delivery_method_type":"EXPRESS","delivery_method_name":"Correios
52
+ Sedex","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false},{"delivery_method_id":1,"delivery_estimate_business_days":12,"provider_shipping_cost":16.45,"final_shipping_cost":16.45,"description":"Correios
53
+ PAC","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":0.167,"delivery_method_type":"STANDARD","delivery_method_name":"Correios
54
+ PAC","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false}],"volumes":[{"weight":0.1,"cost_of_goods":100.0,"width":10.0,"height":10.0,"length":10.0,"description":null,"sku_groups_ids":[],"product_category":null,"volume_type":"BOX"}],"cached":true},"time":"2.1
55
+ ms","timezone":"America/Sao_Paulo","locale":"pt_BR"}'
56
+ http_version:
57
+ recorded_at: Thu, 11 May 2017 00:23:19 GMT
58
+ - request:
59
+ method: get
60
+ uri: https://api.intelipost.com.br/api/v1/quote/1692119094
61
+ body:
62
+ encoding: US-ASCII
63
+ string: ''
64
+ headers:
65
+ platform:
66
+ - intelipost-gem-test
67
+ User-Agent:
68
+ - Faraday v0.12.1
69
+ response:
70
+ status:
71
+ code: 200
72
+ message:
73
+ headers:
74
+ date:
75
+ - Thu, 11 May 2017 00:23:19 GMT
76
+ content-type:
77
+ - application/json; charset=UTF-8
78
+ content-length:
79
+ - '1765'
80
+ connection:
81
+ - close
82
+ server:
83
+ - nginx/1.11.13
84
+ access-control-expose-headers:
85
+ - production
86
+ production:
87
+ - 'false'
88
+ access-control-allow-origin:
89
+ - "*"
90
+ access-control-allow-credentials:
91
+ - 'true'
92
+ access-control-allow-headers:
93
+ - origin, x-requested-with, content-type, api_key, token, production, display-errors,
94
+ api-key, platform, debug, ignore-all-conversion
95
+ access-control-allow-methods:
96
+ - PUT, GET, POST, DELETE, OPTIONS
97
+ x-server:
98
+ - nginx_spr-sae1-prod-application02
99
+ front-end-https:
100
+ - 'on'
101
+ body:
102
+ encoding: UTF-8
103
+ string: '{"status":"OK","messages":[],"content":{"origin_zip_code":"4037003","destination_zip_code":"6396200","platform":"intelipost-gem-test","additional_information":{"extra_cost_absolute":0.0,"lead_time_business_days":0,"free_shipping":false,"delivery_method_ids":[1,2,3],"extra_cost_percentage":0.0,"tax_id":null,"client_type":"gold","sales_channel":"hotsite","payment_type":null,"is_state_tax_payer":null,"shipped_date":null,"calculate_estimated_date_exact":null},"identification":null,"quoting_mode":null,"id":1692119094,"client_id":8554,"created":1494462130059,"created_iso":"2017-05-10T21:22:10.059-03:00","delivery_options":[{"delivery_method_id":2,"delivery_estimate_business_days":8,"provider_shipping_cost":14.87,"final_shipping_cost":14.87,"description":"Correios
104
+ Sedex","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":null,"delivery_method_type":"EXPRESS","delivery_method_name":"Correios
105
+ Sedex","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false},{"delivery_method_id":1,"delivery_estimate_business_days":12,"provider_shipping_cost":16.45,"final_shipping_cost":16.45,"description":"Correios
106
+ PAC","delivery_note":"Entrega domiciliar diferenciada","removed_by_return_modes":false,"removed_by_quote_rules":false,"cubic_weight":null,"delivery_method_type":"STANDARD","delivery_method_name":"Correios
107
+ PAC","logistic_provider_name":"Correios","shown_to_client":true,"scheduling_enabled":false}],"volumes":[{"weight":0.1,"cost_of_goods":100.0,"width":10.0,"height":10.0,"length":10.0,"description":null,"sku_groups_ids":null,"product_category":null,"volume_type":"BOX"}],"cached":false},"time":"3.7
108
+ ms","timezone":"America/Sao_Paulo","locale":"pt_BR"}'
109
+ http_version:
110
+ recorded_at: Thu, 11 May 2017 00:23:19 GMT
111
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.intelipost.com.br/api/v1/cep_location/address_complete/04661100
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ platform:
11
+ - intelipost-gem-test
12
+ User-Agent:
13
+ - Faraday v0.12.1
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ date:
20
+ - Thu, 11 May 2017 00:23:20 GMT
21
+ content-type:
22
+ - application/json; charset=UTF-8
23
+ content-length:
24
+ - '322'
25
+ connection:
26
+ - close
27
+ server:
28
+ - nginx/1.11.13
29
+ access-control-expose-headers:
30
+ - production
31
+ production:
32
+ - 'false'
33
+ access-control-allow-origin:
34
+ - "*"
35
+ access-control-allow-credentials:
36
+ - 'true'
37
+ access-control-allow-headers:
38
+ - origin, x-requested-with, content-type, api_key, token, production, display-errors,
39
+ api-key, platform, debug, ignore-all-conversion
40
+ access-control-allow-methods:
41
+ - PUT, GET, POST, DELETE, OPTIONS
42
+ x-server:
43
+ - nginx_spr-sae1-prod-application03
44
+ front-end-https:
45
+ - 'on'
46
+ body:
47
+ encoding: ASCII-8BIT
48
+ string: !binary |-
49
+ eyJzdGF0dXMiOiJPSyIsIm1lc3NhZ2VzIjpbXSwiY29udGVudCI6eyJzdGF0
50
+ ZSI6IlPDo28gUGF1bG8iLCJjaXR5IjoiU8OjbyBQYXVsbyIsIm5laWdoYm9y
51
+ aG9vZCI6IkphcmRpbSBVbXVhcmFtYSIsInN0cmVldCI6IkF2ZW5pZGEgSW50
52
+ ZXJsYWdvcyIsInN0YXRlX3Nob3J0IjoiU1AiLCJpYmdlIjoiMzU1MDMwOCIs
53
+ ImFkZGl0aW9uYWxfaW5mbyI6Ii0gZGUgODcxIGEgMjI1MSAtIGxhZG8gw61t
54
+ cGFyIiwiYmFpcnJvIjoiSmFyZGltIFVtdWFyYW1hIn0sInRpbWUiOiIwLjEg
55
+ bXMiLCJ0aW1lem9uZSI6IkFtZXJpY2EvU2FvX1BhdWxvIiwibG9jYWxlIjoi
56
+ cHRfQlIifQ==
57
+ http_version:
58
+ recorded_at: Thu, 11 May 2017 00:23:20 GMT
59
+ recorded_with: VCR 2.9.3
@@ -72,10 +72,11 @@ describe Intelipost::Client, :vcr do
72
72
  context "dealing with zipcode (cep)" do
73
73
  it "returns a Intelipost::Mash on successful query" do
74
74
  response = subject.cep.address_complete.get("04661100")
75
+
75
76
  expect(response.class).to eq Intelipost::Mash
76
77
  expect(response.success?).to eq true
77
78
  expect(response.failure?).to eq false
78
- expect(response.all_messages).to eq ""
79
+ expect(response.all_messages).to be_empty
79
80
  expect(response.messages).to be_empty
80
81
  end
81
82
  end
@@ -102,20 +103,21 @@ describe Intelipost::Client, :vcr do
102
103
  "lead_time_business_days" => 0,
103
104
  "sales_channel" => "hotsite",
104
105
  "client_type" => "gold",
105
- "delivery_method_ids" => [ 4, 3, 2 ]
106
+ "delivery_method_ids" => [1, 2, 3]
106
107
  }
107
108
  }
108
109
  end
109
110
 
110
111
  it ".quote.create" do
111
- expect(subject.quote.create(volumes)).to have_key(:content)
112
+ response = subject.quote.create(volumes)
113
+ expect(response).to have_key(:content)
112
114
  end
113
115
 
114
116
  it ".quote.create.failure" do
115
- response = subject.quote.create({"failure"=>"failure"})
117
+ response = subject.quote.create(failure: 'failure')
116
118
  expect(response.success?).to eq false
117
119
  expect(response.failure?).to eq true
118
- expect(response.all_messages).not_to eq ""
120
+ expect(response.all_messages).not_to be_empty
119
121
  expect(response.messages).not_to be_empty
120
122
  end
121
123
 
@@ -1,19 +1,34 @@
1
+ # frozen_string_literal: true
2
+
1
3
  describe Intelipost::Mash do
2
4
  it 'will create a intelipost mash and check if it is a success response' do
3
- mash = Intelipost::Mash.new({status: 'OK'})
5
+ mash = Intelipost::Mash.new(status: 'OK')
6
+
4
7
  expect(mash.success?).to eq true
5
8
  expect(mash.failure?).to eq false
6
9
  expect(mash.all_messages).to eq nil
7
10
  end
8
11
 
9
12
  it 'will create a intelipost mash and check if it is a failure response' do
10
- mash = Intelipost::Mash.new({messages:[
11
- {text: 'some error message'},
12
- {text: 'some error message2'}
13
- ]})
13
+ mash = Intelipost::Mash.new(
14
+ messages: [
15
+ { text: 'some error message' },
16
+ { text: 'some error message2' }
17
+ ]
18
+ )
19
+
14
20
  expect(mash.success?).to eq false
15
21
  expect(mash.failure?).to eq true
16
22
  expect(mash.all_messages).to eq 'some error message;some error message2'
17
23
  end
18
24
 
19
- end
25
+ it 'should override length to avoid conflict with Hash#length method' do
26
+ mash = Intelipost::Mash.new(length: 42)
27
+ expect(mash.length).to eq 42
28
+ end
29
+
30
+ it 'should override key to avoid conflict with Hash#key method' do
31
+ mash = Intelipost::Mash.new(key: 'api-or-other-key')
32
+ expect(mash.key).to eq 'api-or-other-key'
33
+ end
34
+ end
@@ -14,10 +14,15 @@ require 'vcr'
14
14
  Dotenv.load
15
15
 
16
16
  VCR.configure do |c|
17
+ c.default_cassette_options = { record: :new_episodes }
17
18
  c.cassette_library_dir = 'spec/cassettes'
18
- c.hook_into :webmock
19
+ c.hook_into :webmock, :faraday
19
20
  c.configure_rspec_metadata!
20
21
  c.ignore_hosts 'codeclimate.com'
22
+
23
+ c.before_record do |i|
24
+ i.request.headers.delete('api_key')
25
+ end
21
26
  end
22
27
 
23
28
  RSpec.configure do |config|
@@ -25,5 +30,5 @@ RSpec.configure do |config|
25
30
  c.syntax = :expect
26
31
  end
27
32
 
28
- config.order = "random"
33
+ config.order = 'random'
29
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intelipost-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Celestino Gomes
@@ -9,50 +9,68 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-29 00:00:00.000000000 Z
12
+ date: 2017-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.11.0
20
+ version: '0.11'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '1.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '0.11'
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: 0.11.0
33
+ version: '1.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: faraday_middleware
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
- - - "~>"
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.11'
41
+ - - "<"
33
42
  - !ruby/object:Gem::Version
34
- version: 0.11.0
43
+ version: '1.0'
35
44
  type: :runtime
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
38
47
  requirements:
39
- - - "~>"
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0.11'
51
+ - - "<"
40
52
  - !ruby/object:Gem::Version
41
- version: 0.11.0
53
+ version: '1.0'
42
54
  - !ruby/object:Gem::Dependency
43
55
  name: hashie
44
56
  requirement: !ruby/object:Gem::Requirement
45
57
  requirements:
46
- - - "~>"
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '3.5'
61
+ - - "<"
47
62
  - !ruby/object:Gem::Version
48
- version: 3.4.1
63
+ version: '3.6'
49
64
  type: :runtime
50
65
  prerelease: false
51
66
  version_requirements: !ruby/object:Gem::Requirement
52
67
  requirements:
53
- - - "~>"
68
+ - - ">="
54
69
  - !ruby/object:Gem::Version
55
- version: 3.4.1
70
+ version: '3.5'
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.6'
56
74
  - !ruby/object:Gem::Dependency
57
75
  name: bundler
58
76
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +78,9 @@ dependencies:
60
78
  - - ">="
61
79
  - !ruby/object:Gem::Version
62
80
  version: 1.7.6
81
+ - - "<"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.15'
63
84
  type: :development
64
85
  prerelease: false
65
86
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,11 +88,17 @@ dependencies:
67
88
  - - ">="
68
89
  - !ruby/object:Gem::Version
69
90
  version: 1.7.6
91
+ - - "<"
92
+ - !ruby/object:Gem::Version
93
+ version: '1.15'
70
94
  - !ruby/object:Gem::Dependency
71
95
  name: rake
72
96
  requirement: !ruby/object:Gem::Requirement
73
97
  requirements:
74
98
  - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '10.4'
101
+ - - ">="
75
102
  - !ruby/object:Gem::Version
76
103
  version: 10.4.2
77
104
  type: :development
@@ -79,6 +106,9 @@ dependencies:
79
106
  version_requirements: !ruby/object:Gem::Requirement
80
107
  requirements:
81
108
  - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.4'
111
+ - - ">="
82
112
  - !ruby/object:Gem::Version
83
113
  version: 10.4.2
84
114
  - !ruby/object:Gem::Dependency
@@ -86,6 +116,9 @@ dependencies:
86
116
  requirement: !ruby/object:Gem::Requirement
87
117
  requirements:
88
118
  - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '3.2'
121
+ - - ">="
89
122
  - !ruby/object:Gem::Version
90
123
  version: 3.2.0
91
124
  type: :development
@@ -93,6 +126,9 @@ dependencies:
93
126
  version_requirements: !ruby/object:Gem::Requirement
94
127
  requirements:
95
128
  - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.2'
131
+ - - ">="
96
132
  - !ruby/object:Gem::Version
97
133
  version: 3.2.0
98
134
  - !ruby/object:Gem::Dependency
@@ -100,6 +136,9 @@ dependencies:
100
136
  requirement: !ruby/object:Gem::Requirement
101
137
  requirements:
102
138
  - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '2.9'
141
+ - - ">="
103
142
  - !ruby/object:Gem::Version
104
143
  version: 2.9.3
105
144
  type: :development
@@ -107,50 +146,59 @@ dependencies:
107
146
  version_requirements: !ruby/object:Gem::Requirement
108
147
  requirements:
109
148
  - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '2.9'
151
+ - - ">="
110
152
  - !ruby/object:Gem::Version
111
153
  version: 2.9.3
112
154
  - !ruby/object:Gem::Dependency
113
- name: webmock
155
+ name: dotenv
114
156
  requirement: !ruby/object:Gem::Requirement
115
157
  requirements:
116
158
  - - "~>"
117
159
  - !ruby/object:Gem::Version
118
- version: '1.21'
160
+ version: '2.0'
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: 2.0.1
119
164
  type: :development
120
165
  prerelease: false
121
166
  version_requirements: !ruby/object:Gem::Requirement
122
167
  requirements:
123
168
  - - "~>"
124
169
  - !ruby/object:Gem::Version
125
- version: '1.21'
170
+ version: '2.0'
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 2.0.1
126
174
  - !ruby/object:Gem::Dependency
127
- name: simplecov
175
+ name: webmock
128
176
  requirement: !ruby/object:Gem::Requirement
129
177
  requirements:
130
- - - "~>"
178
+ - - '='
131
179
  - !ruby/object:Gem::Version
132
- version: '0.10'
180
+ version: 2.3.2
133
181
  type: :development
134
182
  prerelease: false
135
183
  version_requirements: !ruby/object:Gem::Requirement
136
184
  requirements:
137
- - - "~>"
185
+ - - '='
138
186
  - !ruby/object:Gem::Version
139
- version: '0.10'
187
+ version: 2.3.2
140
188
  - !ruby/object:Gem::Dependency
141
- name: dotenv
189
+ name: simplecov
142
190
  requirement: !ruby/object:Gem::Requirement
143
191
  requirements:
144
192
  - - "~>"
145
193
  - !ruby/object:Gem::Version
146
- version: 2.0.1
194
+ version: '0.10'
147
195
  type: :development
148
196
  prerelease: false
149
197
  version_requirements: !ruby/object:Gem::Requirement
150
198
  requirements:
151
199
  - - "~>"
152
200
  - !ruby/object:Gem::Version
153
- version: 2.0.1
201
+ version: '0.10'
154
202
  - !ruby/object:Gem::Dependency
155
203
  name: codeclimate-test-reporter
156
204
  requirement: !ruby/object:Gem::Requirement
@@ -190,6 +238,10 @@ files:
190
238
  - lib/intelipost/quote.rb
191
239
  - lib/intelipost/shipment_order.rb
192
240
  - lib/intelipost/version.rb
241
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_create.yml
242
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_create_failure.yml
243
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_get_.yml
244
+ - spec/cassettes/Intelipost_Client/dealing_with_zipcode_cep_/returns_a_Intelipost_Mash_on_successful_query.yml
193
245
  - spec/lib/intelipost/cep_spec.rb
194
246
  - spec/lib/intelipost/client_spec.rb
195
247
  - spec/lib/intelipost/mash_spec.rb
@@ -216,11 +268,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
268
  version: '0'
217
269
  requirements: []
218
270
  rubyforge_project:
219
- rubygems_version: 2.6.8
271
+ rubygems_version: 2.5.2
220
272
  signing_key:
221
273
  specification_version: 4
222
274
  summary: Gem to access the REST API of Intelipost
223
275
  test_files:
276
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_create.yml
277
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_create_failure.yml
278
+ - spec/cassettes/Intelipost_Client/dealing_with_Quotes/_quote_get_.yml
279
+ - spec/cassettes/Intelipost_Client/dealing_with_zipcode_cep_/returns_a_Intelipost_Mash_on_successful_query.yml
224
280
  - spec/lib/intelipost/cep_spec.rb
225
281
  - spec/lib/intelipost/client_spec.rb
226
282
  - spec/lib/intelipost/mash_spec.rb