shipengine_ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +305 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +111 -0
- data/LICENSE.txt +21 -0
- data/README.md +14 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/shipengine/client.rb +71 -0
- data/lib/shipengine/configuration.rb +26 -0
- data/lib/shipengine/constants.rb +203 -0
- data/lib/shipengine/domains/addresses.rb +33 -0
- data/lib/shipengine/domains/batches.rb +103 -0
- data/lib/shipengine/domains/carriers.rb +67 -0
- data/lib/shipengine/domains/carriers_accounts.rb +49 -0
- data/lib/shipengine/domains/labels.rb +94 -0
- data/lib/shipengine/domains/manifests.rb +49 -0
- data/lib/shipengine/domains/package_pickups.rb +49 -0
- data/lib/shipengine/domains/package_types.rb +58 -0
- data/lib/shipengine/domains/rates.rb +49 -0
- data/lib/shipengine/domains/service_points.rb +31 -0
- data/lib/shipengine/domains/shipments.rb +103 -0
- data/lib/shipengine/domains/shipsurance.rb +49 -0
- data/lib/shipengine/domains/tags.rb +49 -0
- data/lib/shipengine/domains/tokens.rb +22 -0
- data/lib/shipengine/domains/tracking.rb +40 -0
- data/lib/shipengine/domains/warehouses.rb +58 -0
- data/lib/shipengine/domains/webhooks.rb +58 -0
- data/lib/shipengine/domains.rb +19 -0
- data/lib/shipengine/enums/address_residential_indicator_types.rb +20 -0
- data/lib/shipengine/enums/address_status.rb +34 -0
- data/lib/shipengine/enums/batch_status.rb +34 -0
- data/lib/shipengine/enums/carriers_names.rb +91 -0
- data/lib/shipengine/enums/label_status.rb +22 -0
- data/lib/shipengine/enums/message_types.rb +30 -0
- data/lib/shipengine/enums/validate_address_types.rb +19 -0
- data/lib/shipengine/enums/webhooks_types.rb +52 -0
- data/lib/shipengine/enums.rb +9 -0
- data/lib/shipengine/errors/error_code.rb +224 -0
- data/lib/shipengine/errors/error_source.rb +39 -0
- data/lib/shipengine/errors/error_type.rb +49 -0
- data/lib/shipengine/exceptions.rb +79 -0
- data/lib/shipengine/faraday/raise_http_exception.rb +83 -0
- data/lib/shipengine/utils/validate.rb +102 -0
- data/lib/shipengine/utils.rb +3 -0
- data/lib/shipengine/version.rb +7 -0
- data/lib/shipengine.rb +26 -0
- data/shipengine.gemspec +41 -0
- metadata +249 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e3a9081aefc46e8fe67094b98be084ace56d7d006add7e4fdd311079032a192
|
4
|
+
data.tar.gz: ac2550ae2bd499e780ac2b0e4636bdf2fd5dd8b36bd872494efed6277ff0efc0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 959fe6e248c3565201ee629103aaaf5f9ad23bdbb1fbcdcb47887198d8dffeedf8c52f5f88f2c6ef26544dfe0fede672b9cf6d5d245784b99b53643834fce14e
|
7
|
+
data.tar.gz: 9dda78c41bcf6d60fd2f1d757f2398427c16637fc2d178df13a1a0f994989b8a129b72c1fa230b460bb557884cee10d601eb0de928393fd78b43f43eec042586
|
data/.gitignore
ADDED
@@ -0,0 +1,305 @@
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/ruby,rubymine+all,rails,vim,emacs,visualstudiocode
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=ruby,rubymine+all,rails,vim,emacs,visualstudiocode
|
3
|
+
|
4
|
+
### Emacs ###
|
5
|
+
# -*- mode: gitignore; -*-
|
6
|
+
*~
|
7
|
+
\#*\#
|
8
|
+
/.emacs.desktop
|
9
|
+
/.emacs.desktop.lock
|
10
|
+
*.elc
|
11
|
+
auto-save-list
|
12
|
+
tramp
|
13
|
+
.\#*
|
14
|
+
|
15
|
+
# Org-mode
|
16
|
+
.org-id-locations
|
17
|
+
*_archive
|
18
|
+
|
19
|
+
# flymake-mode
|
20
|
+
*_flymake.*
|
21
|
+
|
22
|
+
# eshell files
|
23
|
+
/eshell/history
|
24
|
+
/eshell/lastdir
|
25
|
+
|
26
|
+
# elpa packages
|
27
|
+
/elpa/
|
28
|
+
|
29
|
+
# reftex files
|
30
|
+
*.rel
|
31
|
+
|
32
|
+
# AUCTeX auto folder
|
33
|
+
/auto/
|
34
|
+
|
35
|
+
# cask packages
|
36
|
+
.cask/
|
37
|
+
dist/
|
38
|
+
|
39
|
+
# Flycheck
|
40
|
+
flycheck_*.el
|
41
|
+
|
42
|
+
# server auth directory
|
43
|
+
/server/
|
44
|
+
|
45
|
+
# projectiles files
|
46
|
+
.projectile
|
47
|
+
|
48
|
+
# directory configuration
|
49
|
+
.dir-locals.el
|
50
|
+
|
51
|
+
# network security
|
52
|
+
/network-security.data
|
53
|
+
|
54
|
+
|
55
|
+
### Rails ###
|
56
|
+
*.rbc
|
57
|
+
capybara-*.html
|
58
|
+
.rspec
|
59
|
+
.rspec_status
|
60
|
+
/db/*.sqlite3
|
61
|
+
/db/*.sqlite3-journal
|
62
|
+
/db/*.sqlite3-[0-9]*
|
63
|
+
/public/system
|
64
|
+
/coverage/
|
65
|
+
/spec/tmp
|
66
|
+
*.orig
|
67
|
+
rerun.txt
|
68
|
+
pickle-email-*.html
|
69
|
+
|
70
|
+
# Ignore all logfiles and tempfiles.
|
71
|
+
/log/*
|
72
|
+
/tmp/*
|
73
|
+
!/log/.keep
|
74
|
+
!/tmp/.keep
|
75
|
+
|
76
|
+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
77
|
+
config/initializers/secret_token.rb
|
78
|
+
config/master.key
|
79
|
+
|
80
|
+
# Only include if you have production secrets in this file, which is no longer a Rails default
|
81
|
+
# config/secrets.yml
|
82
|
+
|
83
|
+
# dotenv, dotenv-rails
|
84
|
+
# TODO Comment out these rules if environment variables can be committed
|
85
|
+
.env
|
86
|
+
.env*.local
|
87
|
+
|
88
|
+
## Environment normalization:
|
89
|
+
/.bundle
|
90
|
+
/vendor/bundle
|
91
|
+
|
92
|
+
# these should all be checked in to normalize the environment:
|
93
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
94
|
+
|
95
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
96
|
+
.rvmrc
|
97
|
+
|
98
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
99
|
+
/vendor/assets/bower_components
|
100
|
+
*.bowerrc
|
101
|
+
bower.json
|
102
|
+
|
103
|
+
# Ignore pow environment settings
|
104
|
+
.powenv
|
105
|
+
|
106
|
+
# Ignore Byebug command history file.
|
107
|
+
.byebug_history
|
108
|
+
|
109
|
+
# Ignore node_modules
|
110
|
+
node_modules/
|
111
|
+
|
112
|
+
# Ignore precompiled javascript packs
|
113
|
+
/public/packs
|
114
|
+
/public/packs-test
|
115
|
+
/public/assets
|
116
|
+
|
117
|
+
# Ignore yarn files
|
118
|
+
/yarn-error.log
|
119
|
+
yarn-debug.log*
|
120
|
+
.yarn-integrity
|
121
|
+
|
122
|
+
# Ignore uploaded files in development
|
123
|
+
/storage/*
|
124
|
+
!/storage/.keep
|
125
|
+
/public/uploads
|
126
|
+
|
127
|
+
### Ruby ###
|
128
|
+
*.gem
|
129
|
+
/.config
|
130
|
+
/InstalledFiles
|
131
|
+
/pkg/
|
132
|
+
/spec/reports/
|
133
|
+
/spec/examples.txt
|
134
|
+
/test/tmp/
|
135
|
+
/test/version_tmp/
|
136
|
+
/tmp/
|
137
|
+
|
138
|
+
# Used by dotenv library to load environment variables.
|
139
|
+
# .env
|
140
|
+
|
141
|
+
# Ignore Byebug command history file.
|
142
|
+
|
143
|
+
## Specific to RubyMotion:
|
144
|
+
.dat*
|
145
|
+
.repl_history
|
146
|
+
build/
|
147
|
+
*.bridgesupport
|
148
|
+
build-iPhoneOS/
|
149
|
+
build-iPhoneSimulator/
|
150
|
+
|
151
|
+
## Specific to RubyMotion (use of CocoaPods):
|
152
|
+
#
|
153
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
154
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
155
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
156
|
+
# vendor/Pods/
|
157
|
+
|
158
|
+
## Documentation cache and generated files:
|
159
|
+
/.yardoc/
|
160
|
+
/_yardoc/
|
161
|
+
/doc/
|
162
|
+
/rdoc/
|
163
|
+
|
164
|
+
/.bundle/
|
165
|
+
/lib/bundler/man/
|
166
|
+
|
167
|
+
# for a library or gem, you might want to ignore these files since the code is
|
168
|
+
# intended to run in multiple environments; otherwise, check them in:
|
169
|
+
# Gemfile.lock
|
170
|
+
# .ruby-version
|
171
|
+
# .ruby-gemset
|
172
|
+
|
173
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
174
|
+
|
175
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
176
|
+
# .rubocop-https?--*
|
177
|
+
|
178
|
+
### RubyMine+all ###
|
179
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
180
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
181
|
+
|
182
|
+
# User-specific stuff
|
183
|
+
.idea/**/workspace.xml
|
184
|
+
.idea/**/tasks.xml
|
185
|
+
.idea/**/usage.statistics.xml
|
186
|
+
.idea/**/dictionaries
|
187
|
+
.idea/**/shelf
|
188
|
+
|
189
|
+
# AWS User-specific
|
190
|
+
.idea/**/aws.xml
|
191
|
+
|
192
|
+
# Generated files
|
193
|
+
.idea/**/contentModel.xml
|
194
|
+
|
195
|
+
# Sensitive or high-churn files
|
196
|
+
.idea/**/dataSources/
|
197
|
+
.idea/**/dataSources.ids
|
198
|
+
.idea/**/dataSources.local.xml
|
199
|
+
.idea/**/sqlDataSources.xml
|
200
|
+
.idea/**/dynamic.xml
|
201
|
+
.idea/**/uiDesigner.xml
|
202
|
+
.idea/**/dbnavigator.xml
|
203
|
+
|
204
|
+
# Gradle
|
205
|
+
.idea/**/gradle.xml
|
206
|
+
.idea/**/libraries
|
207
|
+
|
208
|
+
# Gradle and Maven with auto-import
|
209
|
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
210
|
+
# since they will be recreated, and may cause churn. Uncomment if using
|
211
|
+
# auto-import.
|
212
|
+
# .idea/artifacts
|
213
|
+
# .idea/compiler.xml
|
214
|
+
# .idea/jarRepositories.xml
|
215
|
+
# .idea/modules.xml
|
216
|
+
# .idea/*.iml
|
217
|
+
# .idea/modules
|
218
|
+
# *.iml
|
219
|
+
# *.ipr
|
220
|
+
|
221
|
+
# CMake
|
222
|
+
cmake-build-*/
|
223
|
+
|
224
|
+
# Mongo Explorer plugin
|
225
|
+
.idea/**/mongoSettings.xml
|
226
|
+
|
227
|
+
# File-based project format
|
228
|
+
*.iws
|
229
|
+
|
230
|
+
# IntelliJ
|
231
|
+
out/
|
232
|
+
|
233
|
+
# mpeltonen/sbt-idea plugin
|
234
|
+
.idea_modules/
|
235
|
+
|
236
|
+
# JIRA plugin
|
237
|
+
atlassian-ide-plugin.xml
|
238
|
+
|
239
|
+
# Cursive Clojure plugin
|
240
|
+
.idea/replstate.xml
|
241
|
+
|
242
|
+
# SonarLint plugin
|
243
|
+
.idea/sonarlint/
|
244
|
+
|
245
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
246
|
+
com_crashlytics_export_strings.xml
|
247
|
+
crashlytics.properties
|
248
|
+
crashlytics-build.properties
|
249
|
+
fabric.properties
|
250
|
+
|
251
|
+
# Editor-based Rest Client
|
252
|
+
.idea/httpRequests
|
253
|
+
|
254
|
+
# Android studio 3.1+ serialized cache file
|
255
|
+
.idea/caches/build_file_checksums.ser
|
256
|
+
|
257
|
+
### RubyMine+all Patch ###
|
258
|
+
# Ignore everything but code style settings and run configurations
|
259
|
+
# that are supposed to be shared within teams.
|
260
|
+
|
261
|
+
.idea/*
|
262
|
+
|
263
|
+
!.idea/codeStyles
|
264
|
+
!.idea/runConfigurations
|
265
|
+
|
266
|
+
### Vim ###
|
267
|
+
# Swap
|
268
|
+
[._]*.s[a-v][a-z]
|
269
|
+
!*.svg # comment out if you don't need vector files
|
270
|
+
[._]*.sw[a-p]
|
271
|
+
[._]s[a-rt-v][a-z]
|
272
|
+
[._]ss[a-gi-z]
|
273
|
+
[._]sw[a-p]
|
274
|
+
|
275
|
+
# Session
|
276
|
+
Session.vim
|
277
|
+
Sessionx.vim
|
278
|
+
|
279
|
+
# Temporary
|
280
|
+
.netrwhist
|
281
|
+
# Auto-generated tag files
|
282
|
+
tags
|
283
|
+
# Persistent undo
|
284
|
+
[._]*.un~
|
285
|
+
|
286
|
+
### VisualStudioCode ###
|
287
|
+
.vscode/*
|
288
|
+
!.vscode/settings.json
|
289
|
+
!.vscode/tasks.json
|
290
|
+
!.vscode/launch.json
|
291
|
+
!.vscode/extensions.json
|
292
|
+
!.vscode/*.code-snippets
|
293
|
+
|
294
|
+
# Local History for Visual Studio Code
|
295
|
+
.history/
|
296
|
+
|
297
|
+
# Built Visual Studio Code Extensions
|
298
|
+
*.vsix
|
299
|
+
|
300
|
+
### VisualStudioCode Patch ###
|
301
|
+
# Ignore all local history of files
|
302
|
+
.history
|
303
|
+
.ionide
|
304
|
+
|
305
|
+
# End of https://www.toptal.com/developers/gitignore/api/ruby,rubymine+all,rails,vim,emacs,visualstudiocode
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mohammed@raouf.me. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shipengine (0.0.1)
|
5
|
+
faraday (~> 1.0)
|
6
|
+
faraday_middleware (~> 1.0)
|
7
|
+
hashie (~> 3.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.1)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
coderay (1.1.3)
|
16
|
+
crack (0.4.5)
|
17
|
+
rexml
|
18
|
+
diff-lcs (1.5.0)
|
19
|
+
faraday (1.10.2)
|
20
|
+
faraday-em_http (~> 1.0)
|
21
|
+
faraday-em_synchrony (~> 1.0)
|
22
|
+
faraday-excon (~> 1.1)
|
23
|
+
faraday-httpclient (~> 1.0)
|
24
|
+
faraday-multipart (~> 1.0)
|
25
|
+
faraday-net_http (~> 1.0)
|
26
|
+
faraday-net_http_persistent (~> 1.0)
|
27
|
+
faraday-patron (~> 1.0)
|
28
|
+
faraday-rack (~> 1.0)
|
29
|
+
faraday-retry (~> 1.0)
|
30
|
+
ruby2_keywords (>= 0.0.4)
|
31
|
+
faraday-em_http (1.0.0)
|
32
|
+
faraday-em_synchrony (1.0.0)
|
33
|
+
faraday-excon (1.1.0)
|
34
|
+
faraday-httpclient (1.0.1)
|
35
|
+
faraday-multipart (1.0.4)
|
36
|
+
multipart-post (~> 2)
|
37
|
+
faraday-net_http (1.0.1)
|
38
|
+
faraday-net_http_persistent (1.2.0)
|
39
|
+
faraday-patron (1.0.0)
|
40
|
+
faraday-rack (1.0.0)
|
41
|
+
faraday-retry (1.0.3)
|
42
|
+
faraday_middleware (1.2.0)
|
43
|
+
faraday (~> 1.0)
|
44
|
+
hashdiff (1.0.1)
|
45
|
+
hashie (3.6.0)
|
46
|
+
method_source (1.0.0)
|
47
|
+
multipart-post (2.2.3)
|
48
|
+
parallel (1.22.1)
|
49
|
+
parser (3.1.2.1)
|
50
|
+
ast (~> 2.4.1)
|
51
|
+
pry (0.14.1)
|
52
|
+
coderay (~> 1.1)
|
53
|
+
method_source (~> 1.0)
|
54
|
+
public_suffix (4.0.7)
|
55
|
+
rainbow (3.1.1)
|
56
|
+
rake (13.0.6)
|
57
|
+
regexp_parser (2.6.0)
|
58
|
+
rexml (3.2.5)
|
59
|
+
rspec (3.12.0)
|
60
|
+
rspec-core (~> 3.12.0)
|
61
|
+
rspec-expectations (~> 3.12.0)
|
62
|
+
rspec-mocks (~> 3.12.0)
|
63
|
+
rspec-core (3.12.0)
|
64
|
+
rspec-support (~> 3.12.0)
|
65
|
+
rspec-expectations (3.12.0)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.12.0)
|
68
|
+
rspec-mocks (3.12.0)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.12.0)
|
71
|
+
rspec-support (3.12.0)
|
72
|
+
rubocop (1.28.2)
|
73
|
+
parallel (~> 1.10)
|
74
|
+
parser (>= 3.1.0.0)
|
75
|
+
rainbow (>= 2.2.2, < 4.0)
|
76
|
+
regexp_parser (>= 1.8, < 3.0)
|
77
|
+
rexml
|
78
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
79
|
+
ruby-progressbar (~> 1.7)
|
80
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
81
|
+
rubocop-ast (1.17.0)
|
82
|
+
parser (>= 3.1.1.0)
|
83
|
+
rubocop-performance (1.13.3)
|
84
|
+
rubocop (>= 1.7.0, < 2.0)
|
85
|
+
rubocop-ast (>= 0.4.0)
|
86
|
+
rubocop-shopify (2.5.0)
|
87
|
+
rubocop (~> 1.25)
|
88
|
+
ruby-progressbar (1.11.0)
|
89
|
+
ruby2_keywords (0.0.5)
|
90
|
+
unicode-display_width (2.3.0)
|
91
|
+
webmock (3.18.1)
|
92
|
+
addressable (>= 2.8.0)
|
93
|
+
crack (>= 0.3.2)
|
94
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
bundler (~> 1.17)
|
101
|
+
pry
|
102
|
+
rake
|
103
|
+
rspec
|
104
|
+
rubocop (~> 1.28)
|
105
|
+
rubocop-performance
|
106
|
+
rubocop-shopify
|
107
|
+
shipengine!
|
108
|
+
webmock
|
109
|
+
|
110
|
+
BUNDLED WITH
|
111
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Mohammed Abdel Raouf
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
[![ShipEngine](https://avatars.githubusercontent.com/u/42709242?s=200&v=4)](https://shipengine.com)
|
2
|
+
|
3
|
+
ShipEngine Ruby SDK
|
4
|
+
===================
|
5
|
+
Ruby SDK for [ShipEngine API](https://shipengine.com) offering low-level access as well as convenience methods.
|
6
|
+
|
7
|
+
Quick Start
|
8
|
+
===========
|
9
|
+
|
10
|
+
Install ShipEngine via [RubyGems](https://rubygems.org/)
|
11
|
+
```bash
|
12
|
+
gem install shipengine
|
13
|
+
```
|
14
|
+
- The only configuration requirement is an [API Key](https://www.shipengine.com/docs/auth/#api-keys).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'shipengine'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
12
|
+
|
13
|
+
# require 'irb'
|
14
|
+
# IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday_middleware"
|
4
|
+
require "shipengine/faraday/raise_http_exception"
|
5
|
+
|
6
|
+
# frozen_string_literal: true
|
7
|
+
module ShipEngine
|
8
|
+
class Client
|
9
|
+
# Perform an HTTP GET request
|
10
|
+
def get(path:, options: {})
|
11
|
+
request(method: :get, path: path, options: options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Perform an HTTP POST request
|
15
|
+
def post(path:, options: {})
|
16
|
+
request(method: :post, path: path, options: options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Perform an HTTP PUT request
|
20
|
+
def put(path:, options: {})
|
21
|
+
request(method: :put, path: path, options: options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def patch(path:, options: {})
|
25
|
+
request(method: :patch, path: path, options: options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Perform an HTTP DELETE request
|
29
|
+
def delete(path:, options: {})
|
30
|
+
request(method: :delete, path: path, options: options)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def retry_config
|
36
|
+
{
|
37
|
+
max: ShipEngine.configs.retries,
|
38
|
+
# even though this seems self-evident, this field is necessary for Retry-After to be respected.
|
39
|
+
retry_statuses: [429],
|
40
|
+
# :post is not a "retry_attempt-able request by default"
|
41
|
+
methods: Faraday::Request::Retry::IDEMPOTENT_METHODS + [:post],
|
42
|
+
exceptions: [ShipEngine::Exceptions::RateLimitError],
|
43
|
+
retry_block: proc { |env| env.request_headers["Retries"] = ShipEngine.configs.retries.to_s },
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_connection
|
48
|
+
Faraday.new(url: ShipEngine.configs.base_url) do |conn|
|
49
|
+
conn.headers = {
|
50
|
+
"API-Key" => ShipEngine.configs.api_key, "Accept" => "application/json", "Content-Type" => "application/json",
|
51
|
+
}
|
52
|
+
conn.options.timeout = ShipEngine.configs.timeout / 1000
|
53
|
+
conn.request(:json) # auto-coerce bodies to json
|
54
|
+
conn.request(:retry, retry_config)
|
55
|
+
conn.use(ShipEngine::FaradayMiddleware::RaiseHttpException)
|
56
|
+
conn.response(:json)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def request(method:, path:, options:)
|
61
|
+
create_connection.send(method) do |request|
|
62
|
+
if [:get, :delete].include?(method)
|
63
|
+
request.url(path, options)
|
64
|
+
elsif [:post, :put, :patch].include?(method)
|
65
|
+
request.path = path
|
66
|
+
request.body = options if !options.nil? && !options.empty?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShipEngine
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :api_key, :retries, :base_url, :timeout, :page_size
|
6
|
+
|
7
|
+
def initialize(api_key: nil, retries: nil, timeout: nil, page_size: nil, base_url: nil)
|
8
|
+
@api_key = api_key || ShipEngine::Constants::API_KEY
|
9
|
+
@base_url = base_url || ShipEngine::Constants::PROD_URL
|
10
|
+
@retries = retries || ShipEngine::Constants::RETRIES
|
11
|
+
@timeout = timeout || ShipEngine::Constants::TIMEOUT
|
12
|
+
@page_size = page_size || ShipEngine::Constants::PAGE_SIZE
|
13
|
+
validate
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def validate
|
19
|
+
ShipEngine::Utils::Validate.str("A ShipEngine API key", @api_key)
|
20
|
+
ShipEngine::Utils::Validate.str("Base URL", @base_url)
|
21
|
+
ShipEngine::Utils::Validate.non_neg_int("Retries", @retries)
|
22
|
+
ShipEngine::Utils::Validate.positive_int("Timeout", @timeout)
|
23
|
+
ShipEngine::Utils::Validate.positive_int("Page size", @page_size)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|