easypost 3.5.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +9 -0
  3. data/.github/CODEOWNERS +2 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.yml +81 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.yml +37 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
  7. data/.github/workflows/ci.yml +54 -5
  8. data/.gitignore +27 -17
  9. data/.gitmodules +3 -0
  10. data/CHANGELOG.md +295 -119
  11. data/Gemfile +2 -0
  12. data/Makefile +70 -0
  13. data/README.md +184 -72
  14. data/Rakefile +2 -1
  15. data/UPGRADE_GUIDE.md +181 -0
  16. data/VERSION +1 -1
  17. data/bin/easypost-irb +5 -3
  18. data/easypost.gemspec +27 -20
  19. data/lib/easypost/client.rb +179 -0
  20. data/lib/easypost/connection.rb +64 -0
  21. data/lib/easypost/constants.rb +15 -0
  22. data/lib/easypost/errors/api/api_error.rb +108 -0
  23. data/lib/easypost/errors/api/bad_request_error.rb +6 -0
  24. data/lib/easypost/errors/api/connection_error.rb +6 -0
  25. data/lib/easypost/errors/api/external_api_error.rb +18 -0
  26. data/lib/easypost/errors/api/forbidden_error.rb +6 -0
  27. data/lib/easypost/errors/api/gateway_timeout_error.rb +6 -0
  28. data/lib/easypost/errors/api/internal_server_error.rb +6 -0
  29. data/lib/easypost/errors/api/invalid_request_error.rb +6 -0
  30. data/lib/easypost/errors/api/method_not_allowed_error.rb +6 -0
  31. data/lib/easypost/errors/api/not_found_error.rb +6 -0
  32. data/lib/easypost/errors/api/payment_error.rb +6 -0
  33. data/lib/easypost/errors/api/proxy_error.rb +6 -0
  34. data/lib/easypost/errors/api/rate_limit_error.rb +6 -0
  35. data/lib/easypost/errors/api/redirect_error.rb +6 -0
  36. data/lib/easypost/errors/api/retry_error.rb +6 -0
  37. data/lib/easypost/errors/api/service_unavailable_error.rb +6 -0
  38. data/lib/easypost/errors/api/ssl_error.rb +6 -0
  39. data/lib/easypost/errors/api/timeout_error.rb +6 -0
  40. data/lib/easypost/errors/api/unauthorized_error.rb +6 -0
  41. data/lib/easypost/errors/api/unknown_api_error.rb +6 -0
  42. data/lib/easypost/errors/easy_post_error.rb +7 -0
  43. data/lib/easypost/errors/end_of_pagination_error.rb +7 -0
  44. data/lib/easypost/errors/filtering_error.rb +4 -0
  45. data/lib/easypost/errors/invalid_object_error.rb +4 -0
  46. data/lib/easypost/errors/invalid_parameter_error.rb +11 -0
  47. data/lib/easypost/errors/missing_parameter_error.rb +9 -0
  48. data/lib/easypost/errors/signature_verification_error.rb +4 -0
  49. data/lib/easypost/errors.rb +32 -0
  50. data/lib/easypost/hooks/request_context.rb +16 -0
  51. data/lib/easypost/hooks/response_context.rb +23 -0
  52. data/lib/easypost/hooks.rb +34 -0
  53. data/lib/easypost/http_client.rb +117 -0
  54. data/lib/easypost/internal_utilities.rb +66 -0
  55. data/lib/easypost/models/address.rb +5 -0
  56. data/lib/easypost/models/api_key.rb +5 -0
  57. data/lib/easypost/models/base.rb +58 -0
  58. data/lib/easypost/models/batch.rb +5 -0
  59. data/lib/easypost/models/brand.rb +5 -0
  60. data/lib/easypost/models/carbon_offset.rb +5 -0
  61. data/lib/easypost/models/carrier_account.rb +5 -0
  62. data/lib/easypost/models/carrier_type.rb +5 -0
  63. data/lib/easypost/models/customs_info.rb +5 -0
  64. data/lib/easypost/models/customs_item.rb +5 -0
  65. data/lib/easypost/models/end_shipper.rb +5 -0
  66. data/lib/easypost/models/error.rb +21 -0
  67. data/lib/easypost/models/event.rb +5 -0
  68. data/lib/easypost/models/insurance.rb +6 -0
  69. data/lib/easypost/models/order.rb +9 -0
  70. data/lib/easypost/models/parcel.rb +5 -0
  71. data/lib/easypost/models/payload.rb +5 -0
  72. data/lib/easypost/models/payment_method.rb +5 -0
  73. data/lib/easypost/models/pickup.rb +9 -0
  74. data/lib/easypost/models/pickup_rate.rb +5 -0
  75. data/lib/easypost/models/postage_label.rb +5 -0
  76. data/lib/easypost/models/rate.rb +5 -0
  77. data/lib/easypost/models/referral.rb +5 -0
  78. data/lib/easypost/models/refund.rb +5 -0
  79. data/lib/easypost/models/report.rb +5 -0
  80. data/lib/easypost/models/scan_form.rb +6 -0
  81. data/lib/easypost/models/shipment.rb +10 -0
  82. data/lib/easypost/models/tax_identifier.rb +6 -0
  83. data/lib/easypost/models/tracker.rb +5 -0
  84. data/lib/easypost/models/user.rb +5 -0
  85. data/lib/easypost/models/webhook.rb +6 -0
  86. data/lib/easypost/models.rb +36 -0
  87. data/lib/easypost/services/address.rb +50 -0
  88. data/lib/easypost/services/api_key.rb +8 -0
  89. data/lib/easypost/services/base.rb +27 -0
  90. data/lib/easypost/services/batch.rb +53 -0
  91. data/lib/easypost/services/beta_rate.rb +12 -0
  92. data/lib/easypost/services/beta_referral_customer.rb +40 -0
  93. data/lib/easypost/services/billing.rb +75 -0
  94. data/lib/easypost/services/carrier_account.rb +44 -0
  95. data/lib/easypost/services/carrier_metadata.rb +22 -0
  96. data/lib/easypost/services/carrier_type.rb +10 -0
  97. data/lib/easypost/services/customs_info.rb +17 -0
  98. data/lib/easypost/services/customs_item.rb +15 -0
  99. data/lib/easypost/services/end_shipper.rb +31 -0
  100. data/lib/easypost/services/event.rb +32 -0
  101. data/lib/easypost/services/insurance.rb +26 -0
  102. data/lib/easypost/services/order.rb +30 -0
  103. data/lib/easypost/services/parcel.rb +16 -0
  104. data/lib/easypost/services/pickup.rb +40 -0
  105. data/lib/easypost/services/rate.rb +8 -0
  106. data/lib/easypost/services/referral_customer.rb +103 -0
  107. data/lib/easypost/services/refund.rb +26 -0
  108. data/lib/easypost/services/report.rb +42 -0
  109. data/lib/easypost/services/scan_form.rb +25 -0
  110. data/lib/easypost/services/shipment.rb +106 -0
  111. data/lib/easypost/services/tracker.rb +38 -0
  112. data/lib/easypost/services/user.rb +66 -0
  113. data/lib/easypost/services/webhook.rb +34 -0
  114. data/lib/easypost/services.rb +33 -0
  115. data/lib/easypost/util.rb +160 -116
  116. data/lib/easypost/utilities/constants.rb +5 -0
  117. data/lib/easypost/utilities/json.rb +23 -0
  118. data/lib/easypost/utilities/static_mapper.rb +73 -0
  119. data/lib/easypost/utilities/system.rb +36 -0
  120. data/lib/easypost/version.rb +3 -1
  121. data/lib/easypost.rb +20 -143
  122. metadata +249 -46
  123. data/lib/easypost/address.rb +0 -58
  124. data/lib/easypost/api_key.rb +0 -2
  125. data/lib/easypost/batch.rb +0 -49
  126. data/lib/easypost/brand.rb +0 -9
  127. data/lib/easypost/carrier_account.rb +0 -5
  128. data/lib/easypost/carrier_type.rb +0 -2
  129. data/lib/easypost/customs_info.rb +0 -5
  130. data/lib/easypost/customs_item.rb +0 -5
  131. data/lib/easypost/error.rb +0 -31
  132. data/lib/easypost/event.rb +0 -7
  133. data/lib/easypost/insurance.rb +0 -2
  134. data/lib/easypost/object.rb +0 -151
  135. data/lib/easypost/order.rb +0 -28
  136. data/lib/easypost/parcel.rb +0 -2
  137. data/lib/easypost/pickup.rb +0 -26
  138. data/lib/easypost/pickup_rate.rb +0 -3
  139. data/lib/easypost/postage_label.rb +0 -2
  140. data/lib/easypost/print_job.rb +0 -2
  141. data/lib/easypost/printer.rb +0 -24
  142. data/lib/easypost/rate.rb +0 -2
  143. data/lib/easypost/refund.rb +0 -2
  144. data/lib/easypost/report.rb +0 -29
  145. data/lib/easypost/resource.rb +0 -75
  146. data/lib/easypost/scan_form.rb +0 -6
  147. data/lib/easypost/shipment.rb +0 -129
  148. data/lib/easypost/tax_identifier.rb +0 -2
  149. data/lib/easypost/tracker.rb +0 -7
  150. data/lib/easypost/user.rb +0 -56
  151. data/lib/easypost/webhook.rb +0 -29
@@ -1,2 +0,0 @@
1
- class EasyPost::TaxIdentifier < EasyPost::Resource
2
- end
@@ -1,7 +0,0 @@
1
- class EasyPost::Tracker < EasyPost::Resource
2
- def self.create_list(params={}, api_key=nil)
3
- url = self.url + '/create_list'
4
- response = EasyPost.make_request(:post, url, api_key, params)
5
- return true
6
- end
7
- end
data/lib/easypost/user.rb DELETED
@@ -1,56 +0,0 @@
1
- class EasyPost::User < EasyPost::Resource
2
- def self.create(params = {}, api_key = nil)
3
- response = EasyPost.make_request(:post, url, api_key, {class_name.to_sym => params})
4
- EasyPost::Util.convert_to_easypost_object(response, api_key)
5
- end
6
-
7
- def save
8
- if @unsaved_values.length > 0
9
- values = {}
10
- @unsaved_values.each { |k| values[k] = @values[k] }
11
-
12
- wrapped_params = {user: values}
13
-
14
- response = EasyPost.make_request(:put, url, @api_key, wrapped_params)
15
- refresh_from(response, api_key)
16
- end
17
- self
18
- end
19
-
20
- def self.retrieve_me
21
- all
22
- end
23
-
24
- def self.all_api_keys
25
- EasyPost::ApiKey.all
26
- end
27
-
28
- def api_keys
29
- api_keys = EasyPost::User.all_api_keys
30
-
31
- if api_keys.id == id
32
- my_api_keys = api_keys.keys
33
- else
34
- api_keys.children.each do |child|
35
- if child.id == id
36
- my_api_keys = child.keys
37
- break
38
- end
39
- end
40
- end
41
-
42
- my_api_keys
43
- end
44
-
45
- def update_brand(**attrs)
46
- brand = EasyPost::Brand.new
47
- data = {object: "Brand", user_id: id, **attrs}
48
- # Add accessors manually because there's no API to retrieve a brand
49
- brand.add_accessors(data.keys)
50
- # Assigning values with accessors defined above
51
- data.each do |key, val|
52
- brand.send("#{key}=", val)
53
- end
54
- brand.save
55
- end
56
- end
@@ -1,29 +0,0 @@
1
- class EasyPost::Webhook < EasyPost::Resource
2
- def update(params={})
3
- # NOTE: This method is redefined here since the "url" method conflicts
4
- # with the objects field
5
- unless self.id
6
- raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{self.id.inspect}")
7
- end
8
- instance_url = "#{self.class.url}/#{CGI.escape(id)}"
9
-
10
- response = EasyPost.make_request(:put, instance_url, @api_key, params)
11
- self.refresh_from(response, api_key, true)
12
-
13
- return self
14
- end
15
-
16
- def delete
17
- # NOTE: This method is redefined here since the "url" method conflicts
18
- # with the objects field
19
- unless self.id
20
- raise EasyPost::Error.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{self.id.inspect}")
21
- end
22
- instance_url = "#{self.class.url}/#{CGI.escape(id)}"
23
-
24
- response = EasyPost.make_request(:delete, instance_url, @api_key)
25
- refresh_from(response, api_key)
26
-
27
- return self
28
- end
29
- end