postal_codes_ruby_client 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: 63528c9ac37cefb77cfe7caced39ec75fe84c3a2197f6575cc05adbf85ae1774
4
- data.tar.gz: 1ad109747b05d08e8c3051b6d9a070add6bed73f04167104030b756a4029ca55
3
+ metadata.gz: d654929fa98f22676a1eb822b8cc74c709b980275043467399548ca1cdc10eda
4
+ data.tar.gz: 856da79b975fe3b443ef35de70387d6b80140d99f643d8b08a28430a841ec2f7
5
5
  SHA512:
6
- metadata.gz: a7f11a02eadd625087efde765ca6b6075e3bb3c192e3646498bb7b4b3b27c837c643b291c835bd14a3344065e2dbb96ea754378f62305eb58d8ad41a62ca2058
7
- data.tar.gz: baba39ff1fb569f8c1c676a0d86a7f63b8aae9243bddb8f2597097d73718e7097a32cd287563ba33943cad825329b57990a5d9e041ae377dc526fc40b7957ce0
6
+ metadata.gz: 58c0e4f02f1e0ca59ae8c3ffa995d3950135fdcb8e365a26ef3032401d8bda50de136ebe83c6db643c5a20df5ee7a74259946d52e3c64db76bfd606881e75874
7
+ data.tar.gz: a757c3d0e9a2bc3ab175f9864136499e1d01f5bb6c79c091a1ea0a247a7343114ac81ef0dc435d94604c59555ccda322baa15f139925efc10c03b9f806b081e1
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "uri"
5
- require "json"
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
6
 
7
7
  module PostalCodesRubyClient
8
8
  class Client
@@ -17,9 +17,7 @@ module PostalCodesRubyClient
17
17
  end
18
18
 
19
19
  # Update the API token (e.g. after login or token regeneration).
20
- def api_token=(token)
21
- @api_token = token
22
- end
20
+ attr_writer :api_token
23
21
 
24
22
  # Perform a GET request.
25
23
  def get(path, params = {})
@@ -34,7 +32,7 @@ module PostalCodesRubyClient
34
32
  request = Net::HTTP::Post.new(uri)
35
33
  if body
36
34
  request.body = JSON.generate(body)
37
- request["Content-Type"] = "application/json"
35
+ request['Content-Type'] = 'application/json'
38
36
  end
39
37
  execute(uri, request)
40
38
  end
@@ -48,11 +46,11 @@ module PostalCodesRubyClient
48
46
  end
49
47
 
50
48
  def execute(uri, request)
51
- request["Authorization"] = "Bearer #{@api_token}" if @api_token
52
- request["Accept"] = "application/json"
49
+ request['Authorization'] = "Bearer #{@api_token}" if @api_token
50
+ request['Accept'] = 'application/json'
53
51
 
54
52
  http = Net::HTTP.new(uri.host, uri.port)
55
- http.use_ssl = uri.scheme == "https"
53
+ http.use_ssl = uri.scheme == 'https'
56
54
  http.open_timeout = @timeout
57
55
  http.read_timeout = @timeout
58
56
 
@@ -67,10 +65,10 @@ module PostalCodesRubyClient
67
65
  when 200, 201
68
66
  body
69
67
  when 401
70
- raise AuthenticationError, body&.dig(:error) || "Unauthorized"
68
+ raise AuthenticationError, body&.dig(:error) || 'Unauthorized'
71
69
  when 422
72
70
  raise ValidationError.new(
73
- body&.dig(:error) || "Validation failed",
71
+ body&.dig(:error) || 'Validation failed',
74
72
  errors: body&.dig(:errors) || []
75
73
  )
76
74
  else
@@ -5,7 +5,7 @@ module PostalCodesRubyClient
5
5
  attr_accessor :base_url, :api_token, :timeout
6
6
 
7
7
  def initialize
8
- @base_url = "http://localhost:3000"
8
+ @base_url = 'http://localhost:3000'
9
9
  @api_token = nil
10
10
  @timeout = 30
11
11
  end
@@ -17,14 +17,14 @@ module PostalCodesRubyClient
17
17
  params = { q: q }
18
18
  params[:country] = country if country
19
19
  params[:limit] = limit if limit
20
- @client.get("/api/v1/postal_codes", params)
20
+ @client.get('/api/v1/postal_codes', params)
21
21
  end
22
22
 
23
23
  # List all available country codes.
24
24
  #
25
25
  # @return [Hash] { countries: ["AT", "CH", "DE", ...] }
26
26
  def countries
27
- @client.get("/api/v1/postal_codes/countries")
27
+ @client.get('/api/v1/postal_codes/countries')
28
28
  end
29
29
  end
30
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostalCodesRubyClient
4
- VERSION = "0.1.4"
4
+ VERSION = '0.1.5'
5
5
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "postal_codes_ruby_client/version"
4
- require_relative "postal_codes_ruby_client/configuration"
5
- require_relative "postal_codes_ruby_client/errors"
6
- require_relative "postal_codes_ruby_client/resources/postal_codes"
7
- require_relative "postal_codes_ruby_client/client"
3
+ require_relative 'postal_codes_ruby_client/version'
4
+ require_relative 'postal_codes_ruby_client/configuration'
5
+ require_relative 'postal_codes_ruby_client/errors'
6
+ require_relative 'postal_codes_ruby_client/resources/postal_codes'
7
+ require_relative 'postal_codes_ruby_client/client'
8
8
 
9
9
  module PostalCodesRubyClient
10
10
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postal_codes_ruby_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zauberware technologies
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: webmock
57
71
  requirement: !ruby/object:Gem::Requirement