usps-imis-api 0.10.0 → 0.10.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/Readme.md +15 -1
- data/lib/usps/imis/api.rb +1 -1
- data/lib/usps/imis/business_object.rb +3 -7
- data/lib/usps/imis/properties.rb +14 -14
- data/lib/usps/imis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1bacafdd40f6a1fc863575164f8a29ff135e3f16a4c0dfcc0e2aa6983c55208f
|
|
4
|
+
data.tar.gz: 37854e85dda3f088d48cfa0a9a399f7d1c5e979f74c4d0c57b462090c6bcf8ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 663df0b691ea1add42032df1cfd693667baafc2d39ddd01813c3ada66bf04c52b4bb1285a3d23f387fae17a8842f6be2f06299c88fbee7aff33f3a8aa39f02a2
|
|
7
|
+
data.tar.gz: 839207827b65431fdf565b35cb9c6c98bc4b75d0807ee852ea5bcbfe09c99234b784b77caba2af0e141f04b67afdeec6973e58184f6be3a598ddebcb969173a3
|
data/Readme.md
CHANGED
|
@@ -83,7 +83,21 @@ api.imis_id = imis_id
|
|
|
83
83
|
|
|
84
84
|
#### Without an iMIS ID
|
|
85
85
|
|
|
86
|
-
Running requests without an iMIS ID set will
|
|
86
|
+
Running requests without an iMIS ID set will raise an exception.
|
|
87
|
+
|
|
88
|
+
If you want to query the entire Business Object, use the query interface instead:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
api = Usps::Imis::Api.new # No iMIS ID set
|
|
92
|
+
|
|
93
|
+
# These requests are identical:
|
|
94
|
+
|
|
95
|
+
Usps::Imis::Query.new(api, 'ABC_ASC_Individual_Demog')
|
|
96
|
+
|
|
97
|
+
api.on('ABC_ASC_Individual_Demog').query
|
|
98
|
+
|
|
99
|
+
api.query('ABC_ASC_Individual_Demog')
|
|
100
|
+
```
|
|
87
101
|
|
|
88
102
|
### Business Object and Panel Actions
|
|
89
103
|
|
data/lib/usps/imis/api.rb
CHANGED
|
@@ -106,7 +106,7 @@ module Usps
|
|
|
106
106
|
# @param query_name [String] Full path of the query, e.g. +$/_ABC/Fiander/iMIS_ID+
|
|
107
107
|
# @query_params [Hash] Conforms to pattern +{ param_name => param_value }+
|
|
108
108
|
#
|
|
109
|
-
# @return [
|
|
109
|
+
# @return [Usps::Imis::Query] Query wrapper
|
|
110
110
|
#
|
|
111
111
|
def query(query_name, query_params = {}) = Query.new(self, query_name, **query_params)
|
|
112
112
|
|
|
@@ -35,6 +35,8 @@ module Usps
|
|
|
35
35
|
|
|
36
36
|
# Run a query on the entire business object
|
|
37
37
|
#
|
|
38
|
+
# @return [Usps::Imis::Query] Query wrapper
|
|
39
|
+
#
|
|
38
40
|
def query = api.query(business_object_name)
|
|
39
41
|
|
|
40
42
|
# Get a business object for the current member
|
|
@@ -155,13 +157,7 @@ module Usps
|
|
|
155
157
|
# Skip unmodified fields
|
|
156
158
|
next unless fields.keys.include?(value['Name'])
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
new_value = fields[value['Name']]
|
|
160
|
-
if new_value.is_a?(String)
|
|
161
|
-
value['Value'] = new_value
|
|
162
|
-
else
|
|
163
|
-
value['Value']['$value'] = new_value
|
|
164
|
-
end
|
|
160
|
+
value['Value'] = Properties.wrap(fields[value['Name']])
|
|
165
161
|
|
|
166
162
|
# Add the completed field with the updated value
|
|
167
163
|
updated['Properties']['$values'] << value
|
data/lib/usps/imis/properties.rb
CHANGED
|
@@ -9,6 +9,19 @@ module Usps
|
|
|
9
9
|
#
|
|
10
10
|
def self.build(&) = new.build(&)
|
|
11
11
|
|
|
12
|
+
# Wrap value in the API-internal type structure
|
|
13
|
+
#
|
|
14
|
+
def self.wrap(value)
|
|
15
|
+
case value
|
|
16
|
+
when String then value
|
|
17
|
+
when Time, DateTime then value.strftime('%Y-%m-%dT%H:%I:%S')
|
|
18
|
+
when Integer then { '$type' => 'System.Int32', '$value' => value }
|
|
19
|
+
when true, false then { '$type' => 'System.Boolean', '$value' => value }
|
|
20
|
+
else
|
|
21
|
+
raise Errors::UnexpectedPropertyTypeError.from(value)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
12
25
|
# Build the data for the Properties field
|
|
13
26
|
#
|
|
14
27
|
def build
|
|
@@ -29,22 +42,9 @@ module Usps
|
|
|
29
42
|
@properties << {
|
|
30
43
|
'$type' => 'Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts',
|
|
31
44
|
'Name' => name,
|
|
32
|
-
'Value' => wrap(value)
|
|
45
|
+
'Value' => self.class.wrap(value)
|
|
33
46
|
}
|
|
34
47
|
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def wrap(value)
|
|
39
|
-
case value
|
|
40
|
-
when String then value
|
|
41
|
-
when Time, DateTime then value.strftime('%Y-%m-%dT%H:%I:%S')
|
|
42
|
-
when Integer then { '$type' => 'System.Int32', '$value' => value }
|
|
43
|
-
when true, false then { '$type' => 'System.Boolean', '$value' => value }
|
|
44
|
-
else
|
|
45
|
-
raise Errors::UnexpectedPropertyTypeError.from(value)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
data/lib/usps/imis/version.rb
CHANGED