usps-imis-api 0.11.23 → 1.0.0.pre.rc.1

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +57 -0
  3. data/.gitignore +4 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +88 -0
  6. data/.ruby-version +1 -0
  7. data/.simplecov +8 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +95 -0
  10. data/Rakefile +12 -0
  11. data/Readme.md +191 -19
  12. data/bin/console +21 -0
  13. data/bin/setup +8 -0
  14. data/lib/ext/hash.rb +10 -0
  15. data/lib/usps/imis/api.rb +138 -177
  16. data/lib/usps/imis/config.rb +10 -68
  17. data/lib/usps/imis/error/api.rb +26 -0
  18. data/lib/usps/imis/error/mapper.rb +9 -0
  19. data/lib/usps/imis/{errors/response_error.rb → error/response.rb} +7 -34
  20. data/lib/usps/imis/mapper.rb +21 -90
  21. data/lib/usps/imis/panel/base_panel.rb +42 -0
  22. data/lib/usps/imis/panel/education.rb +111 -0
  23. data/lib/usps/imis/panel/vsc.rb +109 -0
  24. data/lib/usps/imis/version.rb +1 -1
  25. data/lib/usps/imis.rb +17 -32
  26. data/spec/lib/usps/imis/api_spec.rb +143 -0
  27. data/spec/lib/usps/imis/config_spec.rb +33 -0
  28. data/spec/lib/usps/imis/error/api_spec.rb +17 -0
  29. data/spec/lib/usps/imis/error/response_spec.rb +107 -0
  30. data/spec/lib/usps/imis/mapper_spec.rb +31 -0
  31. data/spec/lib/usps/imis/panel/base_panel_spec.rb +32 -0
  32. data/spec/lib/usps/imis/panel/education_spec.rb +55 -0
  33. data/spec/lib/usps/imis/panel/vsc_spec.rb +38 -0
  34. data/spec/lib/usps/imis_spec.rb +11 -0
  35. data/spec/spec_helper.rb +35 -0
  36. data/usps-imis-api.gemspec +18 -0
  37. metadata +33 -94
  38. data/bin/imis +0 -8
  39. data/lib/usps/imis/business_object.rb +0 -209
  40. data/lib/usps/imis/command_line/interface.rb +0 -204
  41. data/lib/usps/imis/command_line/options_parser.rb +0 -136
  42. data/lib/usps/imis/command_line.rb +0 -15
  43. data/lib/usps/imis/data.rb +0 -76
  44. data/lib/usps/imis/error.rb +0 -55
  45. data/lib/usps/imis/errors/api_error.rb +0 -11
  46. data/lib/usps/imis/errors/command_line_error.rb +0 -11
  47. data/lib/usps/imis/errors/config_error.rb +0 -11
  48. data/lib/usps/imis/errors/locked_id_error.rb +0 -15
  49. data/lib/usps/imis/errors/mapper_error.rb +0 -29
  50. data/lib/usps/imis/errors/missing_id_error.rb +0 -15
  51. data/lib/usps/imis/errors/not_found_error.rb +0 -11
  52. data/lib/usps/imis/errors/panel_unimplemented_error.rb +0 -34
  53. data/lib/usps/imis/errors/unexpected_property_type_error.rb +0 -31
  54. data/lib/usps/imis/logger.rb +0 -19
  55. data/lib/usps/imis/logger_formatter.rb +0 -32
  56. data/lib/usps/imis/logger_helpers.rb +0 -17
  57. data/lib/usps/imis/mocks/business_object.rb +0 -47
  58. data/lib/usps/imis/mocks.rb +0 -11
  59. data/lib/usps/imis/panels/base_panel.rb +0 -158
  60. data/lib/usps/imis/panels/education.rb +0 -33
  61. data/lib/usps/imis/panels/vsc.rb +0 -32
  62. data/lib/usps/imis/panels.rb +0 -25
  63. data/lib/usps/imis/properties.rb +0 -50
  64. data/lib/usps/imis/query.rb +0 -153
  65. data/lib/usps/imis/requests.rb +0 -68
  66. data/spec/support/usps/vcr/config.rb +0 -47
  67. data/spec/support/usps/vcr/filters.rb +0 -89
  68. data/spec/support/usps/vcr.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f2842977f938199479a756b99cdf0a9849fa4b006940debfb08a576b92e389e
4
- data.tar.gz: 485c9ed5663f2f538896e563d15991f59a1f8d810728d99b9465078321ecc657
3
+ metadata.gz: 591c0f59f5d39e06c011116940615588936cef78dfb8e497670909d5654c61b8
4
+ data.tar.gz: 2f667e0e06d05a519bff31e6387452dc896aa4204443ceb3ae43d1dab8f2eaf0
5
5
  SHA512:
6
- metadata.gz: 0ad85e740f53e024400bb491c9d818d48185d6dd2bd8dfdbc2a6befc09096034d57d580d96461cd552f5967b5c4b861db733ea352316c29ef8124cb14a7fa5d5
7
- data.tar.gz: 0cbc1a0d52f8dd83bd1a7e2ec04db2963446b804c717cdcd6fbb820ad1bb1e02cb21de49bbfcae05bdd66eb789604213f482e66dd14fa91966d8f79895e7aaf0
6
+ metadata.gz: 622f9629c46f876901542639099e7544d28d932121e7a9bd09513fcdb0c756e2727f6b69aad8ead5606dd36803a80d9f66f2e2c5e4e6cc08fe7133fc799023de
7
+ data.tar.gz: 07ffc1e12820b524083e68d054e23eb976fcd7a16cf48fdbf7d64fe25a5d75b4083e2e6aafd7e6a19671ecaa9a7e2b33240a7bd4aa6d487f4f83fb14316c5aae
@@ -0,0 +1,57 @@
1
+ name: 'USPS iMIS API - Ruby'
2
+ on:
3
+ push:
4
+ paths:
5
+ - '**.rb'
6
+ - '**.yml'
7
+ - '**.json'
8
+ - 'Gemfile'
9
+ - '.simplecov'
10
+ branches:
11
+ - 'main'
12
+ - '**'
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ rubocop:
17
+ runs-on: ubuntu-24.04
18
+ environment: "USPS iMIS API - Ruby"
19
+ strategy:
20
+ matrix:
21
+ ruby: ['3.4', head]
22
+ steps:
23
+ - name: Checkout Code
24
+ uses: actions/checkout@v4
25
+ - name: Setup Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+ - name: Run Rubocop
31
+ run: bundle exec rubocop
32
+ rspec:
33
+ runs-on: ubuntu-24.04
34
+ environment: "USPS iMIS API - Ruby"
35
+ strategy:
36
+ matrix:
37
+ ruby: ['3.4', head]
38
+ env:
39
+ IMIS_USERNAME: ${{ secrets.IMIS_USERNAME }}
40
+ IMIS_PASSWORD: ${{ secrets.IMIS_PASSWORD }}
41
+ IMIS_ID_QUERY_NAME: ${{ secrets.IMIS_ID_QUERY_NAME }}
42
+ steps:
43
+ - name: Checkout Code
44
+ uses: actions/checkout@v4
45
+ - name: Setup Ruby
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
50
+ - name: Run Rspec
51
+ run: bundle exec rspec --format documentation --order rand --color --tty
52
+ - name: Store Coverage
53
+ uses: actions/upload-artifact@v4
54
+ with:
55
+ name: coverage-rspec-${{ matrix.ruby }}
56
+ include-hidden-files: true
57
+ path: coverage/
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ coverage/
2
+ tmp/
3
+ .env
4
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --order rand
data/.rubocop.yml ADDED
@@ -0,0 +1,88 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.4
6
+ Exclude:
7
+ - bin/**/*
8
+ - config/**/*
9
+ - db/**/*
10
+ - vendor/**/*
11
+ - tmp/**/*
12
+ NewCops: enable
13
+ SuggestExtensions: false
14
+
15
+ Layout/FirstHashElementIndentation:
16
+ EnforcedStyle: consistent
17
+ Layout/AccessModifierIndentation:
18
+ EnforcedStyle: outdent
19
+ Layout/EmptyLinesAroundAccessModifier:
20
+ Enabled: true
21
+ Layout/ArrayAlignment:
22
+ Enabled: true
23
+ Layout/HashAlignment:
24
+ Enabled: true
25
+ Layout/EmptyLineAfterGuardClause:
26
+ Enabled: true
27
+ Layout/SpaceInsideBlockBraces:
28
+ EnforcedStyle: space
29
+ EnforcedStyleForEmptyBraces: no_space
30
+ Layout/SpaceInsideHashLiteralBraces:
31
+ EnforcedStyle: space
32
+ EnforcedStyleForEmptyBraces: no_space
33
+ Layout/SpaceInsideArrayLiteralBrackets:
34
+ EnforcedStyle: no_space
35
+ Layout/LineLength:
36
+ Max: 100
37
+
38
+ Lint/UnusedMethodArgument:
39
+ Enabled: true
40
+ Lint/UselessAssignment:
41
+ Enabled: true
42
+
43
+ Metrics/MethodLength:
44
+ Enabled: true
45
+ Max: 15
46
+ Metrics/ClassLength:
47
+ Enabled: true
48
+ Max: 150
49
+ Metrics/ModuleLength:
50
+ Max: 150
51
+ Metrics/ParameterLists:
52
+ Enabled: true
53
+ Metrics/CyclomaticComplexity:
54
+ Enabled: true
55
+ Metrics/AbcSize:
56
+ Enabled: true
57
+ Max: 30
58
+
59
+ Naming/MemoizedInstanceVariableName:
60
+ Enabled: false
61
+ Naming/MethodParameterName:
62
+ Enabled: false
63
+ Naming/FileName:
64
+ Enabled: false
65
+
66
+ Style/Documentation:
67
+ Enabled: false
68
+ Style/FrozenStringLiteralComment:
69
+ Enabled: true
70
+ Style/NumericLiterals:
71
+ Enabled: false
72
+ Style/StringLiterals:
73
+ EnforcedStyle: single_quotes
74
+ Style/AndOr:
75
+ Enabled: true
76
+ Style/ClassCheck:
77
+ Enabled: true
78
+ Style/GuardClause:
79
+ Enabled: true
80
+ Style/OptionalBooleanParameter:
81
+ Enabled: false
82
+
83
+ Security/Eval:
84
+ Enabled: true
85
+ Security/JSONLoad:
86
+ Enabled: true
87
+ Security/YAMLLoad:
88
+ Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.5-dev
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.start do
4
+ enable_coverage :branch
5
+ primary_coverage :branch
6
+
7
+ add_filter '/spec'
8
+ end
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
5
+
6
+ gem 'dotenv', '>= 3.1.4'
7
+ gem 'irb', '>= 1.15.2'
8
+ gem 'rake', '>= 13.2.1'
9
+ gem 'rspec', '>= 3.13.0'
10
+ gem 'rubocop', '>= 1.66.1'
11
+ gem 'rubocop-rspec', '>= 3.1.0'
12
+ gem 'simplecov', '>= 0.22.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ usps-imis-api (1.0.0.pre.rc.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ date (3.4.1)
11
+ diff-lcs (1.5.1)
12
+ docile (1.4.1)
13
+ dotenv (3.1.4)
14
+ erb (5.0.3)
15
+ io-console (0.8.1)
16
+ irb (1.15.2)
17
+ pp (>= 0.6.0)
18
+ rdoc (>= 4.0.0)
19
+ reline (>= 0.4.2)
20
+ json (2.7.2)
21
+ language_server-protocol (3.17.0.3)
22
+ parallel (1.26.3)
23
+ parser (3.3.5.0)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ pp (0.6.3)
27
+ prettyprint
28
+ prettyprint (0.2.0)
29
+ psych (5.2.6)
30
+ date
31
+ stringio
32
+ racc (1.8.1)
33
+ rainbow (3.1.1)
34
+ rake (13.2.1)
35
+ rdoc (6.15.0)
36
+ erb
37
+ psych (>= 4.0.0)
38
+ tsort
39
+ regexp_parser (2.9.2)
40
+ reline (0.6.2)
41
+ io-console (~> 0.5)
42
+ rspec (3.13.0)
43
+ rspec-core (~> 3.13.0)
44
+ rspec-expectations (~> 3.13.0)
45
+ rspec-mocks (~> 3.13.0)
46
+ rspec-core (3.13.1)
47
+ rspec-support (~> 3.13.0)
48
+ rspec-expectations (3.13.3)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.13.0)
51
+ rspec-mocks (3.13.2)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.13.0)
54
+ rspec-support (3.13.1)
55
+ rubocop (1.66.1)
56
+ json (~> 2.3)
57
+ language_server-protocol (>= 3.17.0)
58
+ parallel (~> 1.10)
59
+ parser (>= 3.3.0.2)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 2.4, < 3.0)
62
+ rubocop-ast (>= 1.32.2, < 2.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 2.4.0, < 3.0)
65
+ rubocop-ast (1.32.3)
66
+ parser (>= 3.3.1.0)
67
+ rubocop-rspec (3.1.0)
68
+ rubocop (~> 1.61)
69
+ ruby-progressbar (1.13.0)
70
+ simplecov (0.22.0)
71
+ docile (~> 1.1)
72
+ simplecov-html (~> 0.11)
73
+ simplecov_json_formatter (~> 0.1)
74
+ simplecov-html (0.13.1)
75
+ simplecov_json_formatter (0.1.4)
76
+ stringio (3.1.7)
77
+ tsort (0.2.0)
78
+ unicode-display_width (2.6.0)
79
+
80
+ PLATFORMS
81
+ arm64-darwin-23
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ dotenv (>= 3.1.4)
86
+ irb (>= 1.15.2)
87
+ rake (>= 13.2.1)
88
+ rspec (>= 3.13.0)
89
+ rubocop (>= 1.66.1)
90
+ rubocop-rspec (>= 3.1.0)
91
+ simplecov (>= 0.22.0)
92
+ usps-imis-api!
93
+
94
+ BUNDLED WITH
95
+ 2.5.6
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/Readme.md CHANGED
@@ -13,7 +13,7 @@ gem install usps-imis-api
13
13
  or add this line to your Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'usps-imis-api'
16
+ gem 'usps-imis-api', '>= 0.4.0'
17
17
  ```
18
18
 
19
19
  ## Setup
@@ -25,27 +25,205 @@ require 'dotenv/load' # Optionally load environment variables from `.env` file
25
25
  require 'usps/imis'
26
26
 
27
27
  Usps::Imis.configure do |config|
28
- # This will default to `Rails.env` if available.
29
- config.environment = :development
30
-
31
- # These options will default to the listed `ENV` variable if available.
28
+ config.environment = :development # Rails.env
32
29
  config.imis_id_query_name = ENV['IMIS_ID_QUERY_NAME']
30
+
33
31
  config.username = ENV['IMIS_USERNAME']
34
32
  config.password = ENV['IMIS_PASSWORD']
35
-
36
- # These options will use these defaults
37
- config.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
38
- config.logger.level = :info
39
33
  end
40
34
  ```
41
35
 
36
+ When using `bin/console`, this configuration will be run by default.
37
+
38
+ Instantiate the API object:
39
+
40
+ ```ruby
41
+ api = Usps::Imis::Api.new
42
+ ```
43
+
44
+ If you already have an iMIS ID to work with, you can pass that in immediately:
45
+
46
+ ```ruby
47
+ api = Usps::Imis::Api.new(imis_id: imis_id)
48
+ ```
49
+
50
+ ### Authentication
51
+
52
+ If a token is not available, this will automatically fetch one when needed. As long as that token
53
+ should still be valid, it will reuse the same token. If the token should expire, this will
54
+ automatically request a new token.
55
+
42
56
  ## Usage
43
57
 
44
- For more details and examples, refer to the [Wiki](https://github.com/unitedstatespowersquadrons/imis-api-ruby/wiki).
58
+ ### iMIS ID
59
+
60
+ To act on member data, you need to have the iMIS ID. If you already have access to that from the
61
+ database, you can skip this step.
62
+
63
+ To convert a member's certificate number into their iMIS ID, run the following method:
64
+
65
+ ```ruby
66
+ api.imis_id_for(certificate)
67
+ ```
68
+
69
+ This will both return the ID, and store it for use with other requests. If you need to change which
70
+ member you are working with, just run this method again with the new certificate number.
71
+
72
+ You can also manually set the current ID, if you already have it for a given member
73
+
74
+ ```ruby
75
+ api.imis_id = imis_id
76
+ ```
77
+
78
+ ### GET
79
+
80
+ To fetch member data, run e.g.:
81
+
82
+ ```ruby
83
+ api.imis_id = 31092
84
+
85
+ data = api.get('ABC_ASC_Individual_Demog')
86
+ ```
87
+
88
+ ### PUT Fields
89
+
90
+ To update member data, run e.g.:
91
+
92
+ ```ruby
93
+ api.imis_id = 31092
94
+
95
+ data = { 'MMS_Updated' => Time.now.strftime('%Y-%m-%dT%H:%M:%S'), 'TotMMS' => new_total }
96
+ update = api.put_fields('ABC_ASC_Individual_Demog', data)
97
+ ```
98
+
99
+ This method fetches the current data structure, and filters it down to just what you want to
100
+ update, to reduce the likelihood of update collisions or type validation failures.
101
+
102
+ ### PUT
103
+
104
+ To update member data, run e.g.:
105
+
106
+ ```ruby
107
+ api.imis_id = 31092
108
+
109
+ update = api.put('ABC_ASC_Individual_Demog', complete_imis_object)
110
+ ```
111
+
112
+ This method requires a complete iMIS data structure.
113
+
114
+ ### POST
115
+
116
+ To create new member data, run e.g.:
117
+
118
+ ```ruby
119
+ created = api.post('ABC_ASC_Individual_Demog', complete_imis_object)
120
+ ```
121
+
122
+ This method requires a complete iMIS data structure.
123
+
124
+ ### DELETE
125
+
126
+ To remove member data, run e.g.:
127
+
128
+ ```ruby
129
+ api.imis_id = 31092
130
+
131
+ api.delete('ABC_ASC_Individual_Demog')
132
+ ```
133
+
134
+ This returns a blank string on success.
135
+
136
+ ### QUERY
137
+
138
+ Run an IQA Query
139
+
140
+ `query_params` is a hash of shape: `{ param_name => param_value }`
141
+
142
+ ```ruby
143
+ api.query(query_name, query_params)
144
+ ```
145
+
146
+ ### Field Mapper
147
+
148
+ For fields that have already been mapped between the ITCom database and iMIS, you can use the
149
+ Mapper class to further simplify the update interface:
150
+
151
+ ```ruby
152
+ api.mapper.update(mm: 15)
153
+ ```
154
+
155
+ For simplicity, you can also call `update` on the `Api` class directly:
156
+
157
+ ```ruby
158
+ api.update(mm: 15)
159
+ ```
160
+
161
+ If there is no known mapping for the requested field, the Mapper will give up, but will provide
162
+ you with the standard API call syntax, and will suggest you inform ITCom leadership of the new
163
+ mapping you need.
164
+
165
+ ### Panels
166
+
167
+ For supported panels (usually, business objects with composite identity keys), you can interact
168
+ with them in the same general way:
169
+
170
+ ```ruby
171
+ vsc = Usps::Imis::Panel::Vsc.new
172
+
173
+ vsc.api.imis_id = 6374
174
+
175
+ vsc.get(1417)
176
+
177
+ created = vsc.create(certificate: 'E136924', year: 2024, count: 42)
178
+ ordinal = created['Properties']['$values'][1]['Value']['$value']
179
+
180
+ vsc.update(certificate: 'E136924', year: 2024, count: 43, ordinal: ordinal)
181
+
182
+ vsc.destroy(ordinal)
183
+ ```
184
+
185
+ If you already have an iMIS ID to work with, you can pass that in immediately:
186
+
187
+ ```ruby
188
+ vsc = Usps::Imis::Panel::Vsc.new(imis_id: imis_id)
189
+ ```
190
+
191
+ Panels are also accessible directly from the API object:
192
+
193
+ ```ruby
194
+ api.panels.vsc.get(1417)
195
+ ```
196
+
197
+ ### DSL Mode
198
+
199
+ Instead of manually setting the current iMIS ID, then running individual queries, you can instead
200
+ run queries in DSL mode. This specifies the iMIS ID for the scope of the block, then reverts to the
201
+ previous value.
202
+
203
+ ```ruby
204
+ api.with(31092) do
205
+ # These three requests are identical:
206
+
207
+ put('ABC_ASC_Individual_Demog', { 'TotMMS' => 15 })
208
+
209
+ mapper.update(mm: 15)
210
+
211
+ update(mm: 15)
212
+ end
213
+ ```
214
+
215
+ ```ruby
216
+ api.with(6374) do
217
+ panels.vsc.get(1417)
218
+ end
219
+ ```
45
220
 
46
221
  ## Exception Handling
47
222
 
48
- All internal exceptions inherit from `Usps::Imis::Error`.
223
+ Exception and error response handling will be added later.
224
+
225
+ To print exception information to STDERR when raising, set the environment
226
+ variable `IMIS_ERROR_LOG_TO_STDERR=true`.
49
227
 
50
228
  ## Automated Testing and Linting
51
229
 
@@ -55,16 +233,12 @@ Testing is available by running:
55
233
  bundle exec rspec
56
234
  ```
57
235
 
58
- API web requests are sanitized and recorded using VCR.
59
-
60
236
  Linting is available by running:
61
237
 
62
238
  ```ruby
63
239
  bundle exec rubocop
64
240
  ```
65
241
 
66
- 100% branch coverage is enforced on the test suite.
67
-
68
242
  ### GitHub Actions
69
243
 
70
244
  Testing and linting are automatically run on every push.
@@ -82,7 +256,5 @@ file to [rubygems.org](https://rubygems.org).
82
256
 
83
257
  ## PHP
84
258
 
85
- A wrapper for the CLI from this API is
86
- [available for PHP](https://github.com/unitedstatespowersquadrons/imis-api-php).
87
-
88
- You can also view the [original PHP API](https://github.com/unitedstatespowersquadrons/imis-api).
259
+ This same API is
260
+ [available for PHP](https://github.com/unitedstatespowersquadrons/imis-api).
data/bin/console ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'usps/imis'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # Configure from the environment automatically
11
+ require 'dotenv/load'
12
+ Usps::Imis.configure do |config|
13
+ config.environment = :development
14
+ config.imis_id_query_name = ENV['IMIS_ID_QUERY_NAME']
15
+
16
+ config.username = ENV['IMIS_USERNAME']
17
+ config.password = ENV['IMIS_PASSWORD']
18
+ end
19
+
20
+ require "irb"
21
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/ext/hash.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Import a simplified version of to_query from Rails if not already defined
4
+ class Hash
5
+ def to_query
6
+ map do |key, value|
7
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
8
+ end.sort * '&'
9
+ end
10
+ end