easypost 4.8.1 → 5.1.0
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 +4 -4
- data/.gitattributes +5 -0
- data/.github/workflows/ci.yml +34 -5
- data/.gitignore +27 -20
- data/CHANGELOG.md +56 -0
- data/Makefile +30 -11
- data/README.md +111 -45
- data/UPGRADE_GUIDE.md +119 -0
- data/VERSION +1 -1
- data/easypost.gemspec +14 -10
- data/lib/easypost/client.rb +178 -0
- data/lib/easypost/connection.rb +2 -4
- 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/{carbon_offset.rb → models/carbon_offset.rb} +1 -1
- data/lib/easypost/models/carrier_account.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/{insurance.rb → models/insurance.rb} +1 -1
- 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/{pickup_rate.rb → models/pickup_rate.rb} +1 -1
- data/lib/easypost/{postage_label.rb → models/postage_label.rb} +1 -1
- data/lib/easypost/models/rate.rb +5 -0
- data/lib/easypost/models/referral.rb +5 -0
- data/lib/easypost/{refund.rb → models/refund.rb} +1 -1
- 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/{tax_identifier.rb → models/tax_identifier.rb} +1 -1
- 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 +35 -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/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 +32 -0
- data/lib/easypost/util.rb +116 -161
- 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.rb +14 -136
- metadata +177 -65
- data/.rubocop.yml +0 -11
- data/CODE_OF_CONDUCT.md +0 -16
- data/CONTRIBUTING.md +0 -47
- data/SECURITY.md +0 -7
- data/SUPPORT.md +0 -3
- data/easycop.yml +0 -180
- data/lib/easypost/address.rb +0 -40
- data/lib/easypost/api_key.rb +0 -5
- data/lib/easypost/batch.rb +0 -50
- data/lib/easypost/beta/end_shipper.rb +0 -44
- data/lib/easypost/beta/referral.rb +0 -110
- data/lib/easypost/beta.rb +0 -7
- data/lib/easypost/billing.rb +0 -72
- data/lib/easypost/brand.rb +0 -13
- data/lib/easypost/carrier_account.rb +0 -9
- data/lib/easypost/carrier_type.rb +0 -5
- data/lib/easypost/customs_info.rb +0 -9
- data/lib/easypost/customs_item.rb +0 -9
- data/lib/easypost/end_shipper.rb +0 -24
- data/lib/easypost/error.rb +0 -32
- data/lib/easypost/event.rb +0 -11
- data/lib/easypost/object.rb +0 -171
- data/lib/easypost/order.rb +0 -37
- data/lib/easypost/parcel.rb +0 -9
- data/lib/easypost/payment_method.rb +0 -11
- data/lib/easypost/pickup.rb +0 -37
- data/lib/easypost/rate.rb +0 -9
- data/lib/easypost/referral.rb +0 -102
- data/lib/easypost/report.rb +0 -23
- data/lib/easypost/resource.rb +0 -106
- data/lib/easypost/scan_form.rb +0 -11
- data/lib/easypost/shipment.rb +0 -155
- data/lib/easypost/tracker.rb +0 -12
- data/lib/easypost/user.rb +0 -71
- data/lib/easypost/webhook.rb +0 -57
data/CONTRIBUTING.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Contributing Guide
|
|
2
|
-
|
|
3
|
-
Please read this document in its entirety.
|
|
4
|
-
|
|
5
|
-
## General
|
|
6
|
-
|
|
7
|
-
- Be nice and respectful of maintainers’ and contributors’ time and viewpoints
|
|
8
|
-
- Be as descriptive as possible! More info is always better than not enough
|
|
9
|
-
- Be patient, there may be a lot of in-flight work, some of it across multiple projects not related to the repo being contributed to
|
|
10
|
-
- Have fun!
|
|
11
|
-
|
|
12
|
-
## Contributing
|
|
13
|
-
|
|
14
|
-
Contributing comes in many forms! We are incredibly grateful to anyone who can do any of the following:
|
|
15
|
-
|
|
16
|
-
- Add new features
|
|
17
|
-
- Fix bugs
|
|
18
|
-
- Fix typos
|
|
19
|
-
- Improve docs
|
|
20
|
-
- Improve tests
|
|
21
|
-
- Triage issues
|
|
22
|
-
- Review pull requests
|
|
23
|
-
- Share opinions and viewpoints on issues
|
|
24
|
-
|
|
25
|
-
## Issues
|
|
26
|
-
|
|
27
|
-
- If your issue is security related, please follow the [SECURITY guide](https://github.com/easypost/.github/SECURITY.md)
|
|
28
|
-
- Before opening a new issue, check for existing issues that are related, including closed ones
|
|
29
|
-
- Provide as much information as possible about the issue, including how to reproduce the problem and the expected behavior
|
|
30
|
-
- Don't needlessly bump issues (eg: if there hasn’t been progress for more than a few weeks, feel free to reach back out)
|
|
31
|
-
|
|
32
|
-
## Pull Requests
|
|
33
|
-
|
|
34
|
-
- All Pull Requests should be accompanied first by an issue describing the reason why the Pull Request is needed
|
|
35
|
-
- Be as descriptive as possible in your PR description about why the changes are being made and what the changes contain
|
|
36
|
-
- Pull Requests should be as small as possible
|
|
37
|
-
- Don't make unrelated changes in your Pull Request
|
|
38
|
-
- Don't open a Pull Request if you don't plan to see it through. PRs submitted by individuals that cannot complete additional work to get a PR merged may be closed without completion
|
|
39
|
-
- Adhere to the existing code style of the repo, even if it differs from your personal preference
|
|
40
|
-
- When applicable, add tests that provide ample coverage of the logic added or changed
|
|
41
|
-
- Pull Requests should come from branches and never the default `master` branch
|
|
42
|
-
- Pull Requests must pass CI, including linting and testing
|
|
43
|
-
- Pull Requests must go through code review before they can be merged to the main branch
|
|
44
|
-
- Do not include "version bump" changes in the same PR as your code changes; these will be handled as a separate PR and releasing process
|
|
45
|
-
- Make sure the `Allow edits from maintainers` checkbox is checked. That way EasyPost engineers can make certain minor changes as needed, allowing your pull request to be merged sooner.
|
|
46
|
-
|
|
47
|
-
You agree and acknowledge that you have necessary intellectual property rights to provide your Contribution and hereby assign to EasyPost all right, title and interest in such Contribution.
|
data/SECURITY.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Security Guide
|
|
2
|
-
|
|
3
|
-
We take security seriously at EasyPost. If you find a security issue or vulnerability in our open source projects, please abide by the following guidelines:
|
|
4
|
-
|
|
5
|
-
- Please read our [Responsible Disclosure Policy](https://www.easypost.com/privacy#disclosure-policy).
|
|
6
|
-
- Do not open an issue on GitHub about the security vulnerability. Doing so draws attention to the issue and exposes it to the public.
|
|
7
|
-
- Send an email to `security-abuse@easypost.com` including as many details as possible.
|
data/SUPPORT.md
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
# Support Guide
|
|
2
|
-
|
|
3
|
-
Looking for support for one of our projects? If your question is related to our API, please contact our support team at `support@easypost.com`. If you need support regarding this project, create an issue on GitHub with as many details as possible and we’ll take a look.
|
data/easycop.yml
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
# This file was generated by
|
|
2
|
-
# `rake easycop:init`
|
|
3
|
-
# on 2019-12-16 19:20:52 +0000 using EasyCop version 0.1.
|
|
4
|
-
---
|
|
5
|
-
require:
|
|
6
|
-
- rubocop-rspec
|
|
7
|
-
AllCops:
|
|
8
|
-
TargetRubyVersion: 2.5
|
|
9
|
-
NewCops: disable
|
|
10
|
-
Layout/BlockAlignment:
|
|
11
|
-
Enabled: true
|
|
12
|
-
EnforcedStyleAlignWith: start_of_block
|
|
13
|
-
Layout/DotPosition:
|
|
14
|
-
Enabled: true
|
|
15
|
-
AutoCorrect: true
|
|
16
|
-
EnforcedStyle: leading
|
|
17
|
-
Layout/EmptyLineAfterGuardClause:
|
|
18
|
-
Enabled: true
|
|
19
|
-
AutoCorrect: true
|
|
20
|
-
Layout/EmptyLinesAroundArguments:
|
|
21
|
-
Enabled: true
|
|
22
|
-
AutoCorrect: true
|
|
23
|
-
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
|
24
|
-
Enabled: true
|
|
25
|
-
AutoCorrect: true
|
|
26
|
-
Layout/EndAlignment:
|
|
27
|
-
Enabled: true
|
|
28
|
-
EnforcedStyleAlignWith: keyword
|
|
29
|
-
AutoCorrect: true
|
|
30
|
-
Layout/MultilineMethodCallBraceLayout:
|
|
31
|
-
EnforcedStyle: new_line
|
|
32
|
-
Layout/MultilineHashBraceLayout:
|
|
33
|
-
EnforcedStyle: new_line
|
|
34
|
-
Layout/MultilineArrayBraceLayout:
|
|
35
|
-
EnforcedStyle: new_line
|
|
36
|
-
Layout/FirstArrayElementLineBreak:
|
|
37
|
-
Enabled: true
|
|
38
|
-
Layout/FirstHashElementLineBreak:
|
|
39
|
-
Enabled: true
|
|
40
|
-
Layout/FirstMethodArgumentLineBreak:
|
|
41
|
-
Enabled: true
|
|
42
|
-
Layout/LineLength:
|
|
43
|
-
Max: 120
|
|
44
|
-
IgnoredPatterns: # deprecated in 1.28
|
|
45
|
-
- "(\\A|\\s)#"
|
|
46
|
-
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
|
47
|
-
Enabled: true
|
|
48
|
-
Layout/SpaceBeforeBrackets: # new in 1.7
|
|
49
|
-
Enabled: true
|
|
50
|
-
RSpec/SharedExamples:
|
|
51
|
-
Enabled: false
|
|
52
|
-
RSpec/NestedGroups:
|
|
53
|
-
Enabled: false
|
|
54
|
-
RSpec/ExampleLength:
|
|
55
|
-
Enabled: false
|
|
56
|
-
RSpec/ImplicitSubject:
|
|
57
|
-
Enabled: false
|
|
58
|
-
RSpec/MultipleExpectations:
|
|
59
|
-
Enabled: false
|
|
60
|
-
RSpec/MultipleMemoizedHelpers:
|
|
61
|
-
Enabled: false
|
|
62
|
-
RSpec/IdenticalEqualityAssertion: # new in 2.4
|
|
63
|
-
Enabled: true
|
|
64
|
-
Style/BlockDelimiters:
|
|
65
|
-
Enabled: true
|
|
66
|
-
EnforcedStyle: braces_for_chaining
|
|
67
|
-
Style/ClassAndModuleChildren:
|
|
68
|
-
Enabled: true
|
|
69
|
-
EnforcedStyle: compact
|
|
70
|
-
Style/Documentation:
|
|
71
|
-
Enabled: false
|
|
72
|
-
Style/MethodCalledOnDoEndBlock:
|
|
73
|
-
Severity: warning
|
|
74
|
-
Enabled: true
|
|
75
|
-
Style/RaiseArgs:
|
|
76
|
-
Enabled: false
|
|
77
|
-
Style/RescueStandardError:
|
|
78
|
-
Enabled: true
|
|
79
|
-
Style/MultilineBlockChain:
|
|
80
|
-
Enabled: false
|
|
81
|
-
Style/TrailingCommaInHashLiteral:
|
|
82
|
-
EnforcedStyleForMultiline: consistent_comma
|
|
83
|
-
Style/TrailingCommaInArguments:
|
|
84
|
-
EnforcedStyleForMultiline: consistent_comma
|
|
85
|
-
Style/TrailingCommaInArrayLiteral:
|
|
86
|
-
EnforcedStyleForMultiline: consistent_comma
|
|
87
|
-
Style/SymbolArray:
|
|
88
|
-
Enabled: false
|
|
89
|
-
Style/IfUnlessModifier:
|
|
90
|
-
Enabled: false
|
|
91
|
-
Metrics/BlockLength:
|
|
92
|
-
Enabled: false
|
|
93
|
-
Metrics/ClassLength:
|
|
94
|
-
Enabled: false
|
|
95
|
-
Metrics/CyclomaticComplexity:
|
|
96
|
-
Enabled: false
|
|
97
|
-
Metrics/PerceivedComplexity:
|
|
98
|
-
Enabled: false
|
|
99
|
-
Metrics/ModuleLength:
|
|
100
|
-
Enabled: false
|
|
101
|
-
Metrics/MethodLength:
|
|
102
|
-
Enabled: false
|
|
103
|
-
Metrics/ParameterLists:
|
|
104
|
-
Enabled: false
|
|
105
|
-
Metrics/AbcSize:
|
|
106
|
-
Enabled: false
|
|
107
|
-
Gemspec/DateAssignment: # new in 1.10
|
|
108
|
-
Enabled: true
|
|
109
|
-
Lint/AmbiguousAssignment: # new in 1.7
|
|
110
|
-
Enabled: true
|
|
111
|
-
Lint/AmbiguousRange: # new in 1.19
|
|
112
|
-
Enabled: true
|
|
113
|
-
Lint/DeprecatedConstants: # new in 1.8
|
|
114
|
-
Enabled: true
|
|
115
|
-
Lint/DuplicateBranch: # new in 1.3
|
|
116
|
-
Enabled: true
|
|
117
|
-
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
|
|
118
|
-
Enabled: true
|
|
119
|
-
Lint/EmptyBlock: # new in 1.1
|
|
120
|
-
Enabled: true
|
|
121
|
-
Lint/EmptyClass: # new in 1.3
|
|
122
|
-
Enabled: true
|
|
123
|
-
Lint/EmptyInPattern: # new in 1.16
|
|
124
|
-
Enabled: true
|
|
125
|
-
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
|
126
|
-
Enabled: true
|
|
127
|
-
Lint/NoReturnInBeginEndBlocks: # new in 1.2
|
|
128
|
-
Enabled: true
|
|
129
|
-
Lint/NumberedParameterAssignment: # new in 1.9
|
|
130
|
-
Enabled: true
|
|
131
|
-
Lint/OrAssignmentToConstant: # new in 1.9
|
|
132
|
-
Enabled: true
|
|
133
|
-
Lint/RedundantDirGlobSort: # new in 1.8
|
|
134
|
-
Enabled: true
|
|
135
|
-
Lint/SymbolConversion: # new in 1.9
|
|
136
|
-
Enabled: true
|
|
137
|
-
Lint/ToEnumArguments: # new in 1.1
|
|
138
|
-
Enabled: true
|
|
139
|
-
Lint/TripleQuotes: # new in 1.9
|
|
140
|
-
Enabled: true
|
|
141
|
-
Lint/UnexpectedBlockArity: # new in 1.5
|
|
142
|
-
Enabled: true
|
|
143
|
-
Lint/UnmodifiedReduceAccumulator: # new in 1.1
|
|
144
|
-
Enabled: true
|
|
145
|
-
Naming/InclusiveLanguage: # new in 1.18
|
|
146
|
-
Enabled: true
|
|
147
|
-
Style/ArgumentsForwarding: # new in 1.1
|
|
148
|
-
Enabled: true
|
|
149
|
-
Style/CollectionCompact: # new in 1.2
|
|
150
|
-
Enabled: true
|
|
151
|
-
Style/DocumentDynamicEvalDefinition: # new in 1.1
|
|
152
|
-
Enabled: true
|
|
153
|
-
Style/EndlessMethod: # new in 1.8
|
|
154
|
-
Enabled: true
|
|
155
|
-
Style/HashConversion: # new in 1.10
|
|
156
|
-
Enabled: true
|
|
157
|
-
Style/HashExcept: # new in 1.7
|
|
158
|
-
Enabled: true
|
|
159
|
-
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
|
160
|
-
Enabled: true
|
|
161
|
-
Style/InPatternThen: # new in 1.16
|
|
162
|
-
Enabled: true
|
|
163
|
-
Style/MultilineInPatternThen: # new in 1.16
|
|
164
|
-
Enabled: true
|
|
165
|
-
Style/NegatedIfElseCondition: # new in 1.2
|
|
166
|
-
Enabled: true
|
|
167
|
-
Style/NilLambda: # new in 1.3
|
|
168
|
-
Enabled: true
|
|
169
|
-
Style/QuotedSymbols: # new in 1.16
|
|
170
|
-
Enabled: true
|
|
171
|
-
Style/RedundantArgument: # new in 1.4
|
|
172
|
-
Enabled: true
|
|
173
|
-
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
|
174
|
-
Enabled: true
|
|
175
|
-
Style/StringChars: # new in 1.12
|
|
176
|
-
Enabled: true
|
|
177
|
-
Style/SwapValues: # new in 1.1
|
|
178
|
-
Enabled: true
|
|
179
|
-
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
|
180
|
-
Enabled: true
|
data/lib/easypost/address.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Address objects are used to represent people, places, and organizations in a number of contexts.
|
|
4
|
-
class EasyPost::Address < EasyPost::Resource
|
|
5
|
-
attr_accessor :message # Backwards compatibility
|
|
6
|
-
|
|
7
|
-
# Create an Address.
|
|
8
|
-
def self.create(params = {}, api_key = nil)
|
|
9
|
-
address = params.reject { |k, _| [:verify, :verify_strict].include?(k) }
|
|
10
|
-
|
|
11
|
-
wrapped_params = { address: address }
|
|
12
|
-
|
|
13
|
-
if params[:verify]
|
|
14
|
-
wrapped_params[:verify] = params[:verify]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
if params[:verify_strict]
|
|
18
|
-
wrapped_params[:verify_strict] = params[:verify_strict]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
response = EasyPost.make_request(:post, url, api_key, wrapped_params)
|
|
22
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Create and verify an Address in one call.
|
|
26
|
-
def self.create_and_verify(params = {}, api_key = nil)
|
|
27
|
-
wrapped_params = {}
|
|
28
|
-
wrapped_params[class_name.to_sym] = params
|
|
29
|
-
response = EasyPost.make_request(:post, "#{url}/create_and_verify", api_key, wrapped_params)
|
|
30
|
-
|
|
31
|
-
EasyPost::Util.convert_to_easypost_object(response['address'], api_key)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Verify an Address.
|
|
35
|
-
def verify
|
|
36
|
-
response = EasyPost.make_request(:get, "#{url}/verify", @api_key)
|
|
37
|
-
|
|
38
|
-
EasyPost::Util.convert_to_easypost_object(response['address'], api_key)
|
|
39
|
-
end
|
|
40
|
-
end
|
data/lib/easypost/api_key.rb
DELETED
data/lib/easypost/batch.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# The Batch object allows you to perform operations on multiple Shipments at once.
|
|
4
|
-
class EasyPost::Batch < EasyPost::Resource
|
|
5
|
-
# Create and buy a batch in one call.
|
|
6
|
-
def self.create_and_buy(params = {}, api_key = nil)
|
|
7
|
-
wrapped_params = {}
|
|
8
|
-
wrapped_params[class_name.to_sym] = params
|
|
9
|
-
response = EasyPost.make_request(:post, "#{url}/create_and_buy", api_key, wrapped_params)
|
|
10
|
-
|
|
11
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Buy a Batch.
|
|
15
|
-
def buy(params = {})
|
|
16
|
-
response = EasyPost.make_request(:post, "#{url}/buy", @api_key, params)
|
|
17
|
-
refresh_from(response, @api_key)
|
|
18
|
-
|
|
19
|
-
self
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Convert the label format of a Batch.
|
|
23
|
-
def label(params = {})
|
|
24
|
-
response = EasyPost.make_request(:post, "#{url}/label", @api_key, params)
|
|
25
|
-
refresh_from(response, @api_key)
|
|
26
|
-
|
|
27
|
-
self
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Remove Shipments from a Batch.
|
|
31
|
-
def remove_shipments(params = {})
|
|
32
|
-
response = EasyPost.make_request(:post, "#{url}/remove_shipments", @api_key, params)
|
|
33
|
-
refresh_from(response, @api_key)
|
|
34
|
-
|
|
35
|
-
self
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Add Shipments to a Batch.
|
|
39
|
-
def add_shipments(params = {})
|
|
40
|
-
response = EasyPost.make_request(:post, "#{url}/add_shipments", @api_key, params)
|
|
41
|
-
refresh_from(response, @api_key)
|
|
42
|
-
|
|
43
|
-
self
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Create a ScanForm for a Batch.
|
|
47
|
-
def create_scan_form(params = {})
|
|
48
|
-
EasyPost.make_request(:post, "#{url}/scan_form", @api_key, params)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
|
|
4
|
-
class EasyPost::Beta::EndShipper < EasyPost::Resource
|
|
5
|
-
# Create an EndShipper object.
|
|
6
|
-
# <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
|
|
7
|
-
def self.create(params = {}, api_key = nil)
|
|
8
|
-
warn '[DEPRECATION] Please use `EndShipper.create` in the main namespace instead.'
|
|
9
|
-
response = EasyPost.make_request(:post, '/beta/end_shippers', api_key, { address: params })
|
|
10
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Retrieves an EndShipper object.
|
|
14
|
-
# <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
|
|
15
|
-
def self.retrieve(id, params = {}, api_key = nil)
|
|
16
|
-
warn '[DEPRECATION] Please use `EndShipper.retrieve` in the main namespace instead.'
|
|
17
|
-
response = EasyPost.make_request(:get, "/beta/end_shippers/#{id}", api_key, params)
|
|
18
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Retrieves a list of EndShipper objects.
|
|
22
|
-
# <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
|
|
23
|
-
def self.all(params = {}, api_key = nil)
|
|
24
|
-
warn '[DEPRECATION] Please use `EndShipper.all` in the main namespace instead.'
|
|
25
|
-
response = EasyPost.make_request(:get, '/beta/end_shippers', api_key, params)
|
|
26
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Updates (saves) an EndShipper object. This requires all parameters to be set.
|
|
30
|
-
# <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
|
|
31
|
-
def save
|
|
32
|
-
warn '[DEPRECATION] Please use `endShipper.save` in the main namespace instead.'
|
|
33
|
-
if @unsaved_values.length.positive?
|
|
34
|
-
values = {}
|
|
35
|
-
@unsaved_values.each { |k| values[k] = @values[k] }
|
|
36
|
-
|
|
37
|
-
wrapped_params = { address: values }
|
|
38
|
-
|
|
39
|
-
response = EasyPost.make_request(:put, "/beta/end_shippers/#{id}", @api_key, wrapped_params)
|
|
40
|
-
refresh_from(response, api_key)
|
|
41
|
-
end
|
|
42
|
-
self
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Referral objects are User objects created from a Partner user.
|
|
4
|
-
class EasyPost::Beta::Referral < EasyPost::Resource
|
|
5
|
-
class << self
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
# Retrieve EasyPost's Stripe public API key.
|
|
9
|
-
def retrieve_easypost_stripe_api_key
|
|
10
|
-
response = EasyPost.make_request(:get, '/beta/partners/stripe_public_key', @api_key)
|
|
11
|
-
response['public_key']
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Get credit card token from Stripe.
|
|
15
|
-
def create_stripe_token(number, expiration_month, expiration_year,
|
|
16
|
-
cvc, easypost_stripe_token)
|
|
17
|
-
headers = {
|
|
18
|
-
# This Stripe endpoint only accepts URL form encoded bodies.
|
|
19
|
-
Authorization: "Bearer #{easypost_stripe_token}",
|
|
20
|
-
'Content-type': 'application/x-www-form-urlencoded',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
credit_card_hash = {
|
|
24
|
-
card: {
|
|
25
|
-
number: number,
|
|
26
|
-
exp_month: expiration_month,
|
|
27
|
-
exp_year: expiration_year,
|
|
28
|
-
cvc: cvc,
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
form_encoded_params = EasyPost::Util.form_encode_params(credit_card_hash)
|
|
33
|
-
|
|
34
|
-
uri = URI.parse('https://api.stripe.com/v1/tokens')
|
|
35
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
36
|
-
http.use_ssl = true
|
|
37
|
-
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
|
38
|
-
query = URI.encode_www_form(form_encoded_params)
|
|
39
|
-
|
|
40
|
-
response = http.request(request, query)
|
|
41
|
-
response_json = JSON.parse(response.body)
|
|
42
|
-
response_json['id']
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Submit Stripe credit card token to EasyPost.
|
|
46
|
-
def create_easypost_credit_card(referral_api_key, stripe_object_id, priority = 'primary')
|
|
47
|
-
wrapped_params = {
|
|
48
|
-
credit_card: {
|
|
49
|
-
stripe_object_id: stripe_object_id,
|
|
50
|
-
priority: priority,
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
response = EasyPost.make_request(:post, '/beta/credit_cards', referral_api_key, wrapped_params)
|
|
54
|
-
EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Create a referral user. This function requires the Partner User's API key.
|
|
59
|
-
# <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
|
|
60
|
-
def self.create(params = {}, api_key = nil)
|
|
61
|
-
warn '[DEPRECATION] Please use `Referral.create` in the main namespace instead.'
|
|
62
|
-
response = EasyPost.make_request(:post, '/beta/referral_customers', api_key, { user: params })
|
|
63
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Update a referral user. This function requires the Partner User's API key.
|
|
67
|
-
# <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
|
|
68
|
-
def self.update_email(email, user_id, api_key = nil)
|
|
69
|
-
warn '[DEPRECATION] Please use `Referral.update_email` in the main namespace instead.'
|
|
70
|
-
wrapped_params = {
|
|
71
|
-
user: {
|
|
72
|
-
email: email,
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
EasyPost.make_request(:put, "/beta/referral_customers/#{user_id}", api_key, wrapped_params)
|
|
76
|
-
|
|
77
|
-
# return true if API succeeds, else an error is throw if it fails.
|
|
78
|
-
true
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Retrieve a list of referral users. This function requires the Partner User's API key.
|
|
82
|
-
# <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
|
|
83
|
-
def self.all(params = {}, api_key = nil)
|
|
84
|
-
warn '[DEPRECATION] Please use `Referral.all` in the main namespace instead.'
|
|
85
|
-
response = EasyPost.make_request(:get, '/beta/referral_customers', api_key, params)
|
|
86
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Add credit card to a referral user. This function requires the Referral User's API key.
|
|
90
|
-
# <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
|
|
91
|
-
def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary')
|
|
92
|
-
warn '[DEPRECATION] Please use `Referral.add_credit_card` in the main namespace instead.'
|
|
93
|
-
easypost_stripe_api_key = retrieve_easypost_stripe_api_key
|
|
94
|
-
|
|
95
|
-
begin
|
|
96
|
-
stripe_credit_card_token = create_stripe_token(
|
|
97
|
-
number,
|
|
98
|
-
expiration_month,
|
|
99
|
-
expiration_year,
|
|
100
|
-
cvc,
|
|
101
|
-
easypost_stripe_api_key,
|
|
102
|
-
)
|
|
103
|
-
rescue StandardError
|
|
104
|
-
raise EasyPost::Error.new('Could not send card details to Stripe, please try again later.')
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
response = create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority)
|
|
108
|
-
EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
|
|
109
|
-
end
|
|
110
|
-
end
|
data/lib/easypost/beta.rb
DELETED
data/lib/easypost/billing.rb
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Billing class that users can manage their payment and fund
|
|
4
|
-
class EasyPost::Billing < EasyPost::Resource
|
|
5
|
-
class << self
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
# Get payment method info (type of the payment method and ID of the payment method)
|
|
9
|
-
def get_payment_method_info(primary_or_secondary)
|
|
10
|
-
payment_methods = EasyPost::Billing.retrieve_payment_methods
|
|
11
|
-
payment_method_map = {
|
|
12
|
-
'primary' => 'primary_payment_method',
|
|
13
|
-
'secondary' => 'secondary_payment_method',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
payment_method_to_use = payment_method_map[primary_or_secondary]
|
|
17
|
-
|
|
18
|
-
error_string = 'The chosen payment method is not valid. Please try again.'
|
|
19
|
-
raise EasyPost::Error.new(error_string) if payment_methods[payment_method_to_use].nil?
|
|
20
|
-
|
|
21
|
-
payment_method_id = payment_methods[payment_method_to_use]['id']
|
|
22
|
-
|
|
23
|
-
unless payment_method_id.nil?
|
|
24
|
-
if payment_method_id.start_with?('card_')
|
|
25
|
-
endpoint = '/v2/credit_cards'
|
|
26
|
-
elsif payment_method_id.start_with?('bank_')
|
|
27
|
-
endpoint = '/v2/bank_accounts'
|
|
28
|
-
else
|
|
29
|
-
raise EasyPost::Error.new(error_string)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
[endpoint, payment_method_id]
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Fund your EasyPost wallet by charging your primary or secondary card on file.
|
|
38
|
-
def self.fund_wallet(amount, primary_or_secondary = 'primary', api_key = nil)
|
|
39
|
-
payment_info = get_payment_method_info(primary_or_secondary.downcase)
|
|
40
|
-
endpoint = payment_info[0]
|
|
41
|
-
payment_id = payment_info[1]
|
|
42
|
-
|
|
43
|
-
wrapped_params = { amount: amount }
|
|
44
|
-
EasyPost.make_request(:post, "#{endpoint}/#{payment_id}/charges", api_key, wrapped_params)
|
|
45
|
-
|
|
46
|
-
# Return true if succeeds, an error will be thrown if it fails
|
|
47
|
-
true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Delete a payment method.
|
|
51
|
-
def self.delete_payment_method(primary_or_secondary, api_key = nil)
|
|
52
|
-
payment_info = get_payment_method_info(primary_or_secondary.downcase)
|
|
53
|
-
endpoint = payment_info[0]
|
|
54
|
-
payment_id = payment_info[1]
|
|
55
|
-
|
|
56
|
-
EasyPost.make_request(:delete, "#{endpoint}/#{payment_id}", api_key)
|
|
57
|
-
|
|
58
|
-
# Return true if succeeds, an error will be thrown if it fails
|
|
59
|
-
true
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Retrieve all payment methods.
|
|
63
|
-
def self.retrieve_payment_methods(api_key = nil)
|
|
64
|
-
response = EasyPost.make_request(:get, '/v2/payment_methods', api_key)
|
|
65
|
-
|
|
66
|
-
if response['id'].nil?
|
|
67
|
-
raise EasyPost::Error.new('Billing has not been setup for this user. Please add a payment method.')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
71
|
-
end
|
|
72
|
-
end
|
data/lib/easypost/brand.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# The Brand object allows you to customize the publicly-accessible html page that shows tracking details for every EasyPost tracker.
|
|
4
|
-
class EasyPost::Brand < EasyPost::Resource
|
|
5
|
-
# The url of the Brand object.
|
|
6
|
-
def url
|
|
7
|
-
if user_id.nil? || user_id.empty?
|
|
8
|
-
raise EasyPost::Error, "Missing user_id: #{self.class} instance is missing user_id"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
"#{::EasyPost::User.url}/#{CGI.escape(user_id)}/brand"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# A CarrierAccount encapsulates your credentials with the carrier.
|
|
4
|
-
class EasyPost::CarrierAccount < EasyPost::Resource
|
|
5
|
-
# Retrieve a list of available CarrierAccount types for the authenticated User.
|
|
6
|
-
def self.types
|
|
7
|
-
EasyPost::CarrierType.all
|
|
8
|
-
end
|
|
9
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# CustomsInfo objects contain CustomsItem objects and all necessary information for the generation of customs forms required for international shipping.
|
|
4
|
-
class EasyPost::CustomsInfo < EasyPost::Resource
|
|
5
|
-
# Retrieve a list of CustomsInfo objects
|
|
6
|
-
def self.all(_filters = {}, _api_key = nil)
|
|
7
|
-
raise NotImplementedError.new('CustomsInfo.all not implemented.')
|
|
8
|
-
end
|
|
9
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# A CustomsItem object describes goods for international shipment and should be created then included in a CustomsInfo object.
|
|
4
|
-
class EasyPost::CustomsItem < EasyPost::Resource
|
|
5
|
-
# Retrieve a list of CustomsItem objects
|
|
6
|
-
def self.all(_filters = {}, _api_key = nil)
|
|
7
|
-
raise NotImplementedError.new('CustomsItem.all not implemented.')
|
|
8
|
-
end
|
|
9
|
-
end
|
data/lib/easypost/end_shipper.rb
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
|
|
4
|
-
class EasyPost::EndShipper < EasyPost::Resource
|
|
5
|
-
# Create an EndShipper object.
|
|
6
|
-
def self.create(params = {}, api_key = nil)
|
|
7
|
-
response = EasyPost.make_request(:post, url, api_key, { address: params })
|
|
8
|
-
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Updates (saves) an EndShipper object. This requires all parameters to be set.
|
|
12
|
-
def save
|
|
13
|
-
if @unsaved_values.length.positive?
|
|
14
|
-
values = {}
|
|
15
|
-
@unsaved_values.each { |k| values[k] = @values[k] }
|
|
16
|
-
|
|
17
|
-
wrapped_params = { address: values }
|
|
18
|
-
|
|
19
|
-
response = EasyPost.make_request(:put, url, @api_key, wrapped_params)
|
|
20
|
-
refresh_from(response, api_key)
|
|
21
|
-
end
|
|
22
|
-
self
|
|
23
|
-
end
|
|
24
|
-
end
|