easypost 3.5.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +9 -0
- data/.github/CODEOWNERS +2 -0
- data/.github/ISSUE_TEMPLATE/bug_report.yml +81 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yml +37 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
- data/.github/workflows/ci.yml +54 -5
- data/.gitignore +27 -17
- data/.gitmodules +3 -0
- data/CHANGELOG.md +295 -119
- data/Gemfile +2 -0
- data/Makefile +70 -0
- data/README.md +184 -72
- data/Rakefile +2 -1
- data/UPGRADE_GUIDE.md +181 -0
- data/VERSION +1 -1
- data/bin/easypost-irb +5 -3
- data/easypost.gemspec +27 -20
- data/lib/easypost/client.rb +179 -0
- data/lib/easypost/connection.rb +64 -0
- data/lib/easypost/constants.rb +15 -0
- data/lib/easypost/errors/api/api_error.rb +108 -0
- data/lib/easypost/errors/api/bad_request_error.rb +6 -0
- data/lib/easypost/errors/api/connection_error.rb +6 -0
- data/lib/easypost/errors/api/external_api_error.rb +18 -0
- data/lib/easypost/errors/api/forbidden_error.rb +6 -0
- data/lib/easypost/errors/api/gateway_timeout_error.rb +6 -0
- data/lib/easypost/errors/api/internal_server_error.rb +6 -0
- data/lib/easypost/errors/api/invalid_request_error.rb +6 -0
- data/lib/easypost/errors/api/method_not_allowed_error.rb +6 -0
- data/lib/easypost/errors/api/not_found_error.rb +6 -0
- data/lib/easypost/errors/api/payment_error.rb +6 -0
- data/lib/easypost/errors/api/proxy_error.rb +6 -0
- data/lib/easypost/errors/api/rate_limit_error.rb +6 -0
- data/lib/easypost/errors/api/redirect_error.rb +6 -0
- data/lib/easypost/errors/api/retry_error.rb +6 -0
- data/lib/easypost/errors/api/service_unavailable_error.rb +6 -0
- data/lib/easypost/errors/api/ssl_error.rb +6 -0
- data/lib/easypost/errors/api/timeout_error.rb +6 -0
- data/lib/easypost/errors/api/unauthorized_error.rb +6 -0
- data/lib/easypost/errors/api/unknown_api_error.rb +6 -0
- data/lib/easypost/errors/easy_post_error.rb +7 -0
- data/lib/easypost/errors/end_of_pagination_error.rb +7 -0
- data/lib/easypost/errors/filtering_error.rb +4 -0
- data/lib/easypost/errors/invalid_object_error.rb +4 -0
- data/lib/easypost/errors/invalid_parameter_error.rb +11 -0
- data/lib/easypost/errors/missing_parameter_error.rb +9 -0
- data/lib/easypost/errors/signature_verification_error.rb +4 -0
- data/lib/easypost/errors.rb +32 -0
- data/lib/easypost/hooks/request_context.rb +16 -0
- data/lib/easypost/hooks/response_context.rb +23 -0
- data/lib/easypost/hooks.rb +34 -0
- data/lib/easypost/http_client.rb +117 -0
- data/lib/easypost/internal_utilities.rb +66 -0
- data/lib/easypost/models/address.rb +5 -0
- data/lib/easypost/models/api_key.rb +5 -0
- data/lib/easypost/models/base.rb +58 -0
- data/lib/easypost/models/batch.rb +5 -0
- data/lib/easypost/models/brand.rb +5 -0
- data/lib/easypost/models/carbon_offset.rb +5 -0
- data/lib/easypost/models/carrier_account.rb +5 -0
- data/lib/easypost/models/carrier_type.rb +5 -0
- data/lib/easypost/models/customs_info.rb +5 -0
- data/lib/easypost/models/customs_item.rb +5 -0
- data/lib/easypost/models/end_shipper.rb +5 -0
- data/lib/easypost/models/error.rb +21 -0
- data/lib/easypost/models/event.rb +5 -0
- data/lib/easypost/models/insurance.rb +6 -0
- data/lib/easypost/models/order.rb +9 -0
- data/lib/easypost/models/parcel.rb +5 -0
- data/lib/easypost/models/payload.rb +5 -0
- data/lib/easypost/models/payment_method.rb +5 -0
- data/lib/easypost/models/pickup.rb +9 -0
- data/lib/easypost/models/pickup_rate.rb +5 -0
- data/lib/easypost/models/postage_label.rb +5 -0
- data/lib/easypost/models/rate.rb +5 -0
- data/lib/easypost/models/referral.rb +5 -0
- data/lib/easypost/models/refund.rb +5 -0
- data/lib/easypost/models/report.rb +5 -0
- data/lib/easypost/models/scan_form.rb +6 -0
- data/lib/easypost/models/shipment.rb +10 -0
- data/lib/easypost/models/tax_identifier.rb +6 -0
- data/lib/easypost/models/tracker.rb +5 -0
- data/lib/easypost/models/user.rb +5 -0
- data/lib/easypost/models/webhook.rb +6 -0
- data/lib/easypost/models.rb +36 -0
- data/lib/easypost/services/address.rb +50 -0
- data/lib/easypost/services/api_key.rb +8 -0
- data/lib/easypost/services/base.rb +27 -0
- data/lib/easypost/services/batch.rb +53 -0
- data/lib/easypost/services/beta_rate.rb +12 -0
- data/lib/easypost/services/beta_referral_customer.rb +40 -0
- data/lib/easypost/services/billing.rb +75 -0
- data/lib/easypost/services/carrier_account.rb +44 -0
- data/lib/easypost/services/carrier_metadata.rb +22 -0
- data/lib/easypost/services/carrier_type.rb +10 -0
- data/lib/easypost/services/customs_info.rb +17 -0
- data/lib/easypost/services/customs_item.rb +15 -0
- data/lib/easypost/services/end_shipper.rb +31 -0
- data/lib/easypost/services/event.rb +32 -0
- data/lib/easypost/services/insurance.rb +26 -0
- data/lib/easypost/services/order.rb +30 -0
- data/lib/easypost/services/parcel.rb +16 -0
- data/lib/easypost/services/pickup.rb +40 -0
- data/lib/easypost/services/rate.rb +8 -0
- data/lib/easypost/services/referral_customer.rb +103 -0
- data/lib/easypost/services/refund.rb +26 -0
- data/lib/easypost/services/report.rb +42 -0
- data/lib/easypost/services/scan_form.rb +25 -0
- data/lib/easypost/services/shipment.rb +106 -0
- data/lib/easypost/services/tracker.rb +38 -0
- data/lib/easypost/services/user.rb +66 -0
- data/lib/easypost/services/webhook.rb +34 -0
- data/lib/easypost/services.rb +33 -0
- data/lib/easypost/util.rb +160 -116
- data/lib/easypost/utilities/constants.rb +5 -0
- data/lib/easypost/utilities/json.rb +23 -0
- data/lib/easypost/utilities/static_mapper.rb +73 -0
- data/lib/easypost/utilities/system.rb +36 -0
- data/lib/easypost/version.rb +3 -1
- data/lib/easypost.rb +20 -143
- metadata +249 -46
- data/lib/easypost/address.rb +0 -58
- data/lib/easypost/api_key.rb +0 -2
- data/lib/easypost/batch.rb +0 -49
- data/lib/easypost/brand.rb +0 -9
- data/lib/easypost/carrier_account.rb +0 -5
- data/lib/easypost/carrier_type.rb +0 -2
- data/lib/easypost/customs_info.rb +0 -5
- data/lib/easypost/customs_item.rb +0 -5
- data/lib/easypost/error.rb +0 -31
- data/lib/easypost/event.rb +0 -7
- data/lib/easypost/insurance.rb +0 -2
- data/lib/easypost/object.rb +0 -151
- data/lib/easypost/order.rb +0 -28
- data/lib/easypost/parcel.rb +0 -2
- data/lib/easypost/pickup.rb +0 -26
- data/lib/easypost/pickup_rate.rb +0 -3
- data/lib/easypost/postage_label.rb +0 -2
- data/lib/easypost/print_job.rb +0 -2
- data/lib/easypost/printer.rb +0 -24
- data/lib/easypost/rate.rb +0 -2
- data/lib/easypost/refund.rb +0 -2
- data/lib/easypost/report.rb +0 -29
- data/lib/easypost/resource.rb +0 -75
- data/lib/easypost/scan_form.rb +0 -6
- data/lib/easypost/shipment.rb +0 -129
- data/lib/easypost/tax_identifier.rb +0 -2
- data/lib/easypost/tracker.rb +0 -7
- data/lib/easypost/user.rb +0 -56
- data/lib/easypost/webhook.rb +0 -29
data/lib/easypost/tracker.rb
DELETED
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
|
data/lib/easypost/webhook.rb
DELETED
@@ -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
|