shipengine_ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +305 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +9 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +111 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +14 -0
  10. data/Rakefile +8 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/shipengine/client.rb +71 -0
  14. data/lib/shipengine/configuration.rb +26 -0
  15. data/lib/shipengine/constants.rb +203 -0
  16. data/lib/shipengine/domains/addresses.rb +33 -0
  17. data/lib/shipengine/domains/batches.rb +103 -0
  18. data/lib/shipengine/domains/carriers.rb +67 -0
  19. data/lib/shipengine/domains/carriers_accounts.rb +49 -0
  20. data/lib/shipengine/domains/labels.rb +94 -0
  21. data/lib/shipengine/domains/manifests.rb +49 -0
  22. data/lib/shipengine/domains/package_pickups.rb +49 -0
  23. data/lib/shipengine/domains/package_types.rb +58 -0
  24. data/lib/shipengine/domains/rates.rb +49 -0
  25. data/lib/shipengine/domains/service_points.rb +31 -0
  26. data/lib/shipengine/domains/shipments.rb +103 -0
  27. data/lib/shipengine/domains/shipsurance.rb +49 -0
  28. data/lib/shipengine/domains/tags.rb +49 -0
  29. data/lib/shipengine/domains/tokens.rb +22 -0
  30. data/lib/shipengine/domains/tracking.rb +40 -0
  31. data/lib/shipengine/domains/warehouses.rb +58 -0
  32. data/lib/shipengine/domains/webhooks.rb +58 -0
  33. data/lib/shipengine/domains.rb +19 -0
  34. data/lib/shipengine/enums/address_residential_indicator_types.rb +20 -0
  35. data/lib/shipengine/enums/address_status.rb +34 -0
  36. data/lib/shipengine/enums/batch_status.rb +34 -0
  37. data/lib/shipengine/enums/carriers_names.rb +91 -0
  38. data/lib/shipengine/enums/label_status.rb +22 -0
  39. data/lib/shipengine/enums/message_types.rb +30 -0
  40. data/lib/shipengine/enums/validate_address_types.rb +19 -0
  41. data/lib/shipengine/enums/webhooks_types.rb +52 -0
  42. data/lib/shipengine/enums.rb +9 -0
  43. data/lib/shipengine/errors/error_code.rb +224 -0
  44. data/lib/shipengine/errors/error_source.rb +39 -0
  45. data/lib/shipengine/errors/error_type.rb +49 -0
  46. data/lib/shipengine/exceptions.rb +79 -0
  47. data/lib/shipengine/faraday/raise_http_exception.rb +83 -0
  48. data/lib/shipengine/utils/validate.rb +102 -0
  49. data/lib/shipengine/utils.rb +3 -0
  50. data/lib/shipengine/version.rb +7 -0
  51. data/lib/shipengine.rb +26 -0
  52. data/shipengine.gemspec +41 -0
  53. metadata +249 -0
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class PackageTypes
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_custom_package_types(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.package_types.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def create_custom_package_types(params: {})
22
+ response = @client.post(
23
+ path: ShipEngine::Constants::PATHS.v1.package_types.root,
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def custom_package_types_by_id(package_id:, params: {})
31
+ response = @client.get(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.package_types.root}/#{package_id}",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def update_custom_package_types_by_id(package_id:, params: {})
40
+ response = @client.put(
41
+ path: "#{ShipEngine::Constants::PATHS.v1.package_types.root}/#{package_id}",
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+
48
+ def delete_custom_package_types_by_id(package_id:, params: {})
49
+ response = @client.delete(
50
+ path: "#{ShipEngine::Constants::PATHS.v1.package_types.root}/#{package_id}",
51
+ options: params
52
+ )
53
+
54
+ Hashie::Mash.new(response.body)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Rates
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def shipping_rates(params: {})
13
+ response = @client.post(
14
+ path: ShipEngine::Constants::PATHS.v1.rates.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def bulk_rates(params: {})
22
+ response = @client.post(
23
+ path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/bulk",
24
+ options: params
25
+ )
26
+
27
+ response.body.map { |rate| Hashie::Mash.new(rate) }
28
+ end
29
+
30
+ def estimate_rates(params: {})
31
+ response = @client.post(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/estimate",
33
+ options: params
34
+ )
35
+
36
+ response.body.map { |rate| Hashie::Mash.new(rate) }
37
+ end
38
+
39
+ def rate_by_id(rate_id:, params: {})
40
+ response = @client.get(
41
+ path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/#{rate_id}",
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class ServicePoints
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_service_points(params: {})
13
+ response = @client.post(
14
+ path: "#{ShipEngine::Constants::PATHS.v1.service_points.root}/list",
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def service_point_by_id(carrier_code:, country_code:, service_point_id:, params: {})
22
+ response = @client.get(
23
+ path: "#{ShipEngine::Constants::PATHS.v1.service_points.root}/#{carrier_code}/#{country_code}/#{service_point_id}",
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Shipments
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_shipments(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.shipments.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def create_shipments(params: {})
22
+ response = @client.post(
23
+ path: ShipEngine::Constants::PATHS.v1.shipments.root,
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def shipment_by_external_id(external_shipment_id:, params: {})
31
+ response = @client.get(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.shipment_by_external_id}/#{external_shipment_id}",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def parse_shipping_info(params: {})
40
+ response = @client.put(
41
+ path: ShipEngine::Constants::PATHS.v1.shipments.parse_shipping_info,
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+
48
+ def shipment_by_id(shipment_id:, params: {})
49
+ response = @client.get(
50
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}",
51
+ options: params
52
+ )
53
+
54
+ Hashie::Mash.new(response.body)
55
+ end
56
+
57
+ def update_shipment_by_id(shipment_id:, params: {})
58
+ response = @client.put(
59
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}",
60
+ options: params
61
+ )
62
+
63
+ Hashie::Mash.new(response.body)
64
+ end
65
+
66
+ def cancel_shipment_by_id(shipment_id:, params: {})
67
+ response = @client.delete(
68
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}",
69
+ options: params
70
+ )
71
+
72
+ Hashie::Mash.new(response.body)
73
+ end
74
+
75
+ def shipment_rates(shipment_id:, params: {})
76
+ response = @client.get(
77
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}/rates",
78
+ options: params
79
+ )
80
+
81
+ Hashie::Mash.new(response.body)
82
+ end
83
+
84
+ def add_tag_to_shipment(shipment_id:, tag_name:, params: {})
85
+ response = @client.post(
86
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}/tags/#{tag_name}",
87
+ options: params
88
+ )
89
+
90
+ Hashie::Mash.new(response.body)
91
+ end
92
+
93
+ def remove_tag_to_shipment(shipment_id:, tag_name:, params: {})
94
+ response = @client.delete(
95
+ path: "#{ShipEngine::Constants::PATHS.v1.shipments.root}/#{shipment_id}/tags/#{tag_name}",
96
+ options: params
97
+ )
98
+
99
+ Hashie::Mash.new(response.body)
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Shipsurance
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def disconnect_shipsurance_account(params: {})
13
+ response = @client.delete(
14
+ path: ShipEngine::Constants::PATHS.v1.shipsurance.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def connect_shipsurance_account(params: {})
22
+ response = @client.post(
23
+ path: ShipEngine::Constants::PATHS.v1.shipsurance.root,
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def add_funds_to_insurance(params: {})
31
+ response = @client.patch(
32
+ path: ShipEngine::Constants::PATHS.v1.shipsurance.add_funds,
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def get_insurance_funds_balance(params: {})
40
+ response = @client.get(
41
+ path: ShipEngine::Constants::PATHS.v1.shipsurance.balance,
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Tags
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_tags(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.tags.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def create_tag(tag_name:, params: {})
22
+ response = @client.post(
23
+ path: "#{ShipEngine::Constants::PATHS.v1.tags.root}/#{tag_name}",
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def delete_tag(tag_name:, params: {})
31
+ response = @client.delete(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.tags.root}/#{tag_name}",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def update_tag(tag_name:, new_tag_name:, params: {})
40
+ response = @client.put(
41
+ path: "#{ShipEngine::Constants::PATHS.v1.tags.root}/#{tag_name}/#{new_tag_name}",
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Tokens
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def ephemeral_token(params: {})
13
+ response = @client.post(
14
+ path: ShipEngine::Constants::PATHS.v1.tokens.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Tracking
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def tracking_information(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.tracking.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def start_tracking_package(params: {})
22
+ response = @client.post(
23
+ path: "#{ShipEngine::Constants::PATHS.v1.tracking.root}/start",
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def stop_tracking_package(params: {})
31
+ response = @client.post(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.tracking.root}/stop",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Warehouses
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_warehouses(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.warehouses.root,
15
+ options: params
16
+ )
17
+
18
+ Hashie::Mash.new(response.body)
19
+ end
20
+
21
+ def create_warehouse(params: {})
22
+ response = @client.post(
23
+ path: ShipEngine::Constants::PATHS.v1.warehouses.root,
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def warehouse_by_id(warehouse_id:, params: {})
31
+ response = @client.get(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.warehouses.root}/#{warehouse_id}",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def update_warehouse_by_id(warehouse_id:, params: {})
40
+ response = @client.put(
41
+ path: "#{ShipEngine::Constants::PATHS.v1.warehouses.root}/#{warehouse_id}",
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+
48
+ def delete_warehouse_by_id(warehouse_id:, params: {})
49
+ response = @client.delete(
50
+ path: "#{ShipEngine::Constants::PATHS.v1.warehouses.root}/#{warehouse_id}",
51
+ options: params
52
+ )
53
+
54
+ Hashie::Mash.new(response.body)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hashie"
4
+
5
+ module ShipEngine
6
+ module Domain
7
+ class Webhooks
8
+ def initialize
9
+ @client = ShipEngine::Client.new
10
+ end
11
+
12
+ def list_webhooks(params: {})
13
+ response = @client.get(
14
+ path: ShipEngine::Constants::PATHS.v1.webhooks.root,
15
+ options: params
16
+ )
17
+
18
+ response.body.map { |webhook| Hashie::Mash.new(webhook) }
19
+ end
20
+
21
+ def create_webhook(params: {})
22
+ response = @client.post(
23
+ path: ShipEngine::Constants::PATHS.v1.webhooks.root,
24
+ options: params
25
+ )
26
+
27
+ Hashie::Mash.new(response.body)
28
+ end
29
+
30
+ def webhook_by_id(webhook_id:, params: {})
31
+ response = @client.get(
32
+ path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
33
+ options: params
34
+ )
35
+
36
+ Hashie::Mash.new(response.body)
37
+ end
38
+
39
+ def update_webhook_by_id(webhook_id:, params: {})
40
+ response = @client.put(
41
+ path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
42
+ options: params
43
+ )
44
+
45
+ Hashie::Mash.new(response.body)
46
+ end
47
+
48
+ def delete_webhook_by_id(webhook_id:, params: {})
49
+ response = @client.delete(
50
+ path: "#{ShipEngine::Constants::PATHS.v1.webhooks.root}/#{webhook_id}",
51
+ options: params
52
+ )
53
+
54
+ Hashie::Mash.new(response.body)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shipengine/domains/addresses"
4
+ require "shipengine/domains/batches"
5
+ require "shipengine/domains/carriers"
6
+ require "shipengine/domains/carriers_accounts"
7
+ require "shipengine/domains/labels"
8
+ require "shipengine/domains/manifests"
9
+ require "shipengine/domains/package_pickups"
10
+ require "shipengine/domains/package_types"
11
+ require "shipengine/domains/rates"
12
+ require "shipengine/domains/service_points"
13
+ require "shipengine/domains/shipments"
14
+ require "shipengine/domains/shipsurance"
15
+ require "shipengine/domains/tags"
16
+ require "shipengine/domains/tokens"
17
+ require "shipengine/domains/tracking"
18
+ require "shipengine/domains/warehouses"
19
+ require "shipengine/domains/webhooks"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShipEngine
4
+ module Enums
5
+ module AddressResidentialIndicatorTypes
6
+
7
+ UNKNOWN = "unknown"
8
+
9
+ YES = "yes"
10
+
11
+ NO = "no"
12
+
13
+ ALL = [
14
+ UNKNOWN,
15
+ YES,
16
+ NO,
17
+ ].freeze
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShipEngine
4
+ module Enums
5
+ module AddressStatus
6
+ #
7
+ # Address validation was not validated against the database because pre-validation failed.
8
+ #
9
+ UNVERIFIED = "unverified"
10
+
11
+ #
12
+ # Address was successfully verified.
13
+ #
14
+ VERIFIED = "verified"
15
+
16
+ #
17
+ # The address was validated, but the address should be double checked.
18
+ #
19
+ WARNING = "warning"
20
+
21
+ #
22
+ # The address could not be validated with any degree of certainty against the database.
23
+ #
24
+ ERROR = "error"
25
+
26
+ ALL = [
27
+ UNVERIFIED,
28
+ VERIFIED,
29
+ WARNING,
30
+ ERROR,
31
+ ].freeze
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShipEngine
4
+ module Enums
5
+ module BatchStatus
6
+ OPEN = "open"
7
+
8
+ QUEUED = "queued"
9
+
10
+ PROCESSING = "processing"
11
+
12
+ COMPLETED = "completed"
13
+
14
+ COMPLETED_WITH_ERRORS = "completed_with_errors"
15
+
16
+ ARCHIVED = "archived"
17
+
18
+ NOTIFYING = "notifying"
19
+
20
+ INVALID = "invalid"
21
+
22
+ ALL = [
23
+ OPEN,
24
+ QUEUED,
25
+ PROCESSING,
26
+ COMPLETED,
27
+ COMPLETED_WITH_ERRORS,
28
+ ARCHIVED,
29
+ NOTIFYING,
30
+ INVALID,
31
+ ].freeze
32
+ end
33
+ end
34
+ end