usps-imis-api 0.1.0 → 0.1.1.pre.2
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/Readme.md +160 -0
- data/usps-imis-api.gemspec +1 -1
- metadata +3 -2
- /data/lib/{usps_imis_api.rb → usps-imis-api.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6547c9f21c818bf196c1679ba6f34380d87499148212b4257c12a66d938fd3d1
|
4
|
+
data.tar.gz: e68b6e5d91999b9e4a94b31303528a019b626724bec05df11fe84137c1430782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8deac689f8ef2fa6d5330df7790d178f9240e6d0da994c203877bb58585fc7865aa5f48c1e4959ba9b580f245f20f6516fab408eabc250b650b973da80fbe3b4
|
7
|
+
data.tar.gz: 5ceac354048e28443019fe0286b60275c2333c0ad9c6700710d823b500b53a2805941fe2add4f2e5e372719e29723474f2ca1cbfe0416cfae72e0e5c221b6915
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/Readme.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# USPS iMIS API for Ruby
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run this command:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem install usps-imis-api
|
11
|
+
```
|
12
|
+
|
13
|
+
or add this line to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'usps-imis-api', '>= 0.1.0'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Setup
|
20
|
+
|
21
|
+
Include the library, and set the configuration:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'dotenv/load' # Optionally load environment variables from `.env` file
|
25
|
+
require 'usps_imis_api'
|
26
|
+
|
27
|
+
Imis.configure do |config|
|
28
|
+
config.environment = :development # Rails.env
|
29
|
+
config.imis_id_query_name = ENV['IMIS_ID_QUERY_NAME']
|
30
|
+
|
31
|
+
config.username = ENV['IMIS_USERNAME']
|
32
|
+
config.password = ENV['IMIS_PASSWORD']
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
Instantiate the API object:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
api = Imis::Api.new
|
40
|
+
```
|
41
|
+
|
42
|
+
### Authentication
|
43
|
+
|
44
|
+
If a token is not available, this will automatically fetch one when needed. As long as that token
|
45
|
+
should still be valid, it will reuse the same token. If the token should expire, this will
|
46
|
+
automatically request a new token.
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
### iMIS ID
|
51
|
+
|
52
|
+
To act on member data, you need to have the iMIS ID. If you already have access to that from the
|
53
|
+
database, you can skip this step.
|
54
|
+
|
55
|
+
To convert a member's certificate number into their iMIS ID, run the following method:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
api.get_imis_id(certificate)
|
59
|
+
```
|
60
|
+
|
61
|
+
This will both return the ID, and store it for use with other requests. If you need to change which
|
62
|
+
member you are working with, just run this method again with the new certificate number.
|
63
|
+
|
64
|
+
### General API Requests
|
65
|
+
|
66
|
+
#### GET
|
67
|
+
|
68
|
+
To fetch member data, run e.g.:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
api.imis_id = 31092
|
72
|
+
|
73
|
+
data = api.get('ABC_ASC_Individual_Demog')
|
74
|
+
```
|
75
|
+
|
76
|
+
#### PUT
|
77
|
+
|
78
|
+
To update member data, run e.g.:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
api.imis_id = 31092
|
82
|
+
|
83
|
+
data = { 'MMS_Updated' => Time.now.strftime('%Y-%m-%dT%H:%M:%S'), 'TotMMS' => new_total }
|
84
|
+
update = api.put_object_fields('ABC_ASC_Individual_Demog', data)
|
85
|
+
```
|
86
|
+
|
87
|
+
This method fetches the current data structure, and filters it down to just what you want to
|
88
|
+
update, to reduce the likelihood of update collisions or type validation failures.
|
89
|
+
|
90
|
+
### Public Methods
|
91
|
+
|
92
|
+
Convert a member's certificate number into an iMIS ID number
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
api.get_imis_id(certificate)
|
96
|
+
```
|
97
|
+
|
98
|
+
Manually set the current ID, if you already have it for a given member
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
api.imis_id = imis_id
|
102
|
+
```
|
103
|
+
|
104
|
+
GET a business object for the current member
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
api.get(business_object_name)
|
108
|
+
```
|
109
|
+
|
110
|
+
Update only specific fields on a business object for the current member
|
111
|
+
|
112
|
+
`fields` is a hash of shape: `{ field_name => new_value }`
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
api.put(business_object_name, fields)
|
116
|
+
```
|
117
|
+
|
118
|
+
Run an IQA Query
|
119
|
+
|
120
|
+
`query_params` is a hash of shape: `{ param_name => param_value }`
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
api.query(query_name, query_params)
|
124
|
+
```
|
125
|
+
|
126
|
+
### Field Mapper
|
127
|
+
|
128
|
+
For fields that have already been mapped between the ITCom database and iMIS, you can use the
|
129
|
+
Mapper class to further simplify the update interface:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
api.mapper.update(:mm, 15)
|
133
|
+
```
|
134
|
+
|
135
|
+
If there is no known mapping for the requested field, the Mapper will give up, but will provide
|
136
|
+
you with the standard API call syntax, and will suggest you inform ITCom leadership of the new
|
137
|
+
mapping you need.
|
138
|
+
|
139
|
+
## Exception Handling
|
140
|
+
|
141
|
+
Exception and error response handling will be added later.
|
142
|
+
|
143
|
+
## Automated Testing and Linting
|
144
|
+
|
145
|
+
Testing is available by running:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
bundle exec rspec
|
149
|
+
```
|
150
|
+
|
151
|
+
Linting is available by running:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
bundle exec rubocop
|
155
|
+
```
|
156
|
+
|
157
|
+
## PHP
|
158
|
+
|
159
|
+
This same API is
|
160
|
+
[available for PHP](https://github.com/unitedstatespowersquadrons/imis-api).
|
data/usps-imis-api.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usps-imis-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
@@ -22,13 +22,14 @@ files:
|
|
22
22
|
- ".ruby-version"
|
23
23
|
- Gemfile
|
24
24
|
- Gemfile.lock
|
25
|
+
- Readme.md
|
25
26
|
- lib/ext/hash.rb
|
26
27
|
- lib/imis/api.rb
|
27
28
|
- lib/imis/config.rb
|
28
29
|
- lib/imis/error/api.rb
|
29
30
|
- lib/imis/error/mapper.rb
|
30
31
|
- lib/imis/mapper.rb
|
31
|
-
- lib/
|
32
|
+
- lib/usps-imis-api.rb
|
32
33
|
- spec/api_spec.rb
|
33
34
|
- spec/mapper_spec.rb
|
34
35
|
- spec/spec_helper.rb
|
File without changes
|