easyship 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: 1c6c501de616b3a63e0d2115bcd85edd664d19457e15cee9ddc39b90460faf06
4
- data.tar.gz: c28725fd205ad6c7943bc3af5ec230c6dfa0a3a9a605a36caaab01d9ff6b4120
3
+ metadata.gz: 26a4f14b66c264e247eba786be5a7e7c69e364b15bd82fb3a0b972d3738a2291
4
+ data.tar.gz: a602f6940102161c1b6e2e9e8a9714f7cd2e2576f5d4d5e04621d8119d7dbc06
5
5
  SHA512:
6
- metadata.gz: d3e59ba1d63fccd367093dd0d0cfa2c4e853be57820384e7ab033929f808adffca7313633009dc6b7804d3c54d8130ab3f8da45586e31c59865a903c4b906e38
7
- data.tar.gz: db7d3fb69ea674cfc5a9ee6527193ce637bf123b74d51f104a821de4f0c9273d3cb4d25621e8ea6b885f852f16c09e2c87485e6845b04bb4e1f70ad4aff319d2
6
+ metadata.gz: 2548182a0a00f80abe3096a247f1a85b0878f8ed737f370813e169de5a0db67fc982080fc7650eae22a931f844adfc465566e27cfb331d381744ca53e038693d
7
+ data.tar.gz: c5be671de26cefaa90af42d8b5f22ddb32af00e84dcc4ad57db9a8fd193b05902a6b60fdc093968e7781ac523ca066cd322c9a478ea637cf8ca775f79fce329e
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ AllCops:
7
7
  NewCops: enable
8
8
 
9
9
  Style/Copyright:
10
- Enabled: false
10
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [v0.1.5](https://github.com/mmarusyk/easyship/tree/v0.1.5) - 2025-05-03
4
+
5
+ ### Fixed
6
+ - update docs by @troyizzle in https://github.com/mmarusyk/easyship/pull/5
7
+ - Add test coverage by @mmarusyk in https://github.com/mmarusyk/easyship/pull/6
8
+ - Automate release by @mmarusyk in https://github.com/mmarusyk/easyship/pull/7
3
9
 
4
10
  ## [v0.1.4](https://github.com/mmarusyk/easyship/tree/v0.1.4) - 2024-10-16
5
11
 
data/README.md CHANGED
@@ -59,7 +59,7 @@ Configuration supports the next keys: `url`, `api_key`, `per_page`.
59
59
  ### Making Requests
60
60
  `Easyship::Client` supports the next methods: `get`, `post`, `put`, `delete`.
61
61
  ```ruby
62
- Easyship::Client.get('/2023-01/account')
62
+ Easyship::Client.instance.get('/2023-01/account')
63
63
  ```
64
64
 
65
65
  To make post request:
@@ -84,7 +84,7 @@ payload = {
84
84
  ]
85
85
  }
86
86
 
87
- Easyship::Client.post('/2023-01/shipment', payload)
87
+ Easyship::Client.instance.post('/2023-01/shipment', payload)
88
88
  ```
89
89
 
90
90
  ### Handle errors
@@ -97,7 +97,7 @@ For example:
97
97
 
98
98
  ```ruby
99
99
  begin
100
- Easyship::Client.post('/2023-01/shipment', payload)
100
+ Easyship::Client.instance.post('/2023-01/shipment', payload)
101
101
  rescue Easyship::Errors::RateLimitError => e
102
102
  Rails.logger.error("Easyship Error: #{e.message}")
103
103
  end
@@ -5,7 +5,23 @@ Dir[File.join(__dir__, 'errors', '**', '*.rb')].each { |f| require_relative f }
5
5
  module Easyship
6
6
  # Represents a mapping of HTTP status codes to Easyship-specific classes
7
7
  class Error
8
- # rubocop:disable Style::MutableConstant Style::MissingElse
8
+ class << self
9
+ def for_status(status_code)
10
+ ERRORS[status_code] || default_error_for(status_code)
11
+ end
12
+
13
+ private
14
+
15
+ def default_error_for(status_code)
16
+ case status_code.to_s
17
+ when /4\d{2}/
18
+ Easyship::Errors::ClientError
19
+ when /5\d{2}/
20
+ Easyship::Errors::ServerError
21
+ end
22
+ end
23
+ end
24
+
9
25
  ERRORS = {
10
26
  400 => Easyship::Errors::BadRequestError,
11
27
  401 => Easyship::Errors::InvalidTokenError,
@@ -13,18 +29,6 @@ module Easyship
13
29
  404 => Easyship::Errors::ResourceNotFoundError,
14
30
  422 => Easyship::Errors::UnprocessableContentError,
15
31
  429 => Easyship::Errors::RateLimitError
16
- }
17
-
18
- ERRORS.default_proc = proc do |_hash, key|
19
- case key.to_s
20
- when /4\d{2}/
21
- Easyship::Errors::ClientError
22
- when /5\d{2}/
23
- Easyship::Errors::ServerError
24
- end
25
- end
26
- # rubocop:enable Style::MutableConstant Style::MissingElse
27
-
28
- ERRORS.freeze
32
+ }.freeze
29
33
  end
30
34
  end
@@ -16,7 +16,7 @@ module Easyship
16
16
  private
17
17
 
18
18
  def handle_status_code(status_code, body)
19
- error_class = Easyship::Error::ERRORS[status_code]
19
+ error_class = Easyship::Error.for_status(status_code)
20
20
 
21
21
  raise_error(error_class, body) if error_class
22
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Easyship
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyship
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
  - Michael Marusyk
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -68,7 +67,6 @@ metadata:
68
67
  allowed_push_host: https://rubygems.org
69
68
  source_code_uri: https://github.com/mmarusyk/easyship
70
69
  changelog_uri: https://github.com/mmarusyk/easyship/blob/main/CHANGELOG.md
71
- post_install_message:
72
70
  rdoc_options: []
73
71
  require_paths:
74
72
  - lib
@@ -83,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
81
  - !ruby/object:Gem::Version
84
82
  version: '0'
85
83
  requirements: []
86
- rubygems_version: 3.5.16
87
- signing_key:
84
+ rubygems_version: 3.6.7
88
85
  specification_version: 4
89
86
  summary: A Ruby client for integrating with Easyship's API for shipping and logistics
90
87
  management.