usps-imis-api 0.6.12 → 0.6.13
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/Gemfile.lock +1 -1
- data/lib/usps/imis/api.rb +7 -9
- data/lib/usps/imis/business_object.rb +16 -8
- data/lib/usps/imis/panel/base_panel.rb +4 -6
- 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: ce718cab17b65f021cb739faa943d2437f2f4e83f051ad50c37a9ae0cfe48131
|
|
4
|
+
data.tar.gz: 34cece880ed383d43536f915b1c9480fe557587a61d69c9ed32c061932bbfd3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a05b5e0bc67ac874b306e688decd19d61c28d4a734165817395f2194a5ac2e166c5e75bcfc900488036f83941c81b4fd0c840810a261813d8b2ae343d5597608
|
|
7
|
+
data.tar.gz: aa402f52a26d2eb0d44928d9461707bc671d6ebf4f3e85325407762d2529b09668b02c2970f58528ad125d1e36c87718439817307f676b0858d764ac358cc7df
|
data/Gemfile.lock
CHANGED
data/lib/usps/imis/api.rb
CHANGED
|
@@ -135,10 +135,10 @@ module Usps
|
|
|
135
135
|
# An instance of +BusinessObject+, using this instance as its parent +Api+
|
|
136
136
|
#
|
|
137
137
|
# @param business_object_name [String] Name of the business object
|
|
138
|
-
# @param
|
|
138
|
+
# @param ordinal [Integer] Ordinal to build override ID param of the URL (e.g. used for Panels)
|
|
139
139
|
#
|
|
140
|
-
def business_object(business_object_name,
|
|
141
|
-
BusinessObject.new(self, business_object_name,
|
|
140
|
+
def business_object(business_object_name, ordinal: nil)
|
|
141
|
+
BusinessObject.new(self, business_object_name, ordinal:)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
# Run requests as DSL, with specific +BusinessObject+ only maintained for this scope
|
|
@@ -146,15 +146,13 @@ module Usps
|
|
|
146
146
|
# If no block is given, this returns the specified +BusinessObject+.
|
|
147
147
|
#
|
|
148
148
|
# @param business_object_name [String] Name of the business object
|
|
149
|
-
# @param
|
|
149
|
+
# @param ordinal [Integer] Ordinal to build override ID param of the URL (e.g. used for Panels)
|
|
150
150
|
#
|
|
151
|
-
def on(business_object_name,
|
|
152
|
-
object = business_object(business_object_name,
|
|
151
|
+
def on(business_object_name, ordinal: nil, &)
|
|
152
|
+
object = business_object(business_object_name, ordinal:)
|
|
153
153
|
return object unless block_given?
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
object.tap { |obj| result = obj.instance_eval(&) }
|
|
157
|
-
result
|
|
155
|
+
object.instance_eval(&)
|
|
158
156
|
end
|
|
159
157
|
|
|
160
158
|
# An instance of +Mapper+, using this instance as its parent +Api+
|
|
@@ -18,16 +18,16 @@ module Usps
|
|
|
18
18
|
#
|
|
19
19
|
attr_reader :business_object_name
|
|
20
20
|
|
|
21
|
-
#
|
|
21
|
+
# Ordinal to build override ID param of the URL (e.g. used for Panels)
|
|
22
22
|
#
|
|
23
|
-
attr_reader :
|
|
23
|
+
attr_reader :ordinal
|
|
24
24
|
|
|
25
25
|
# A new instance of +BusinessObject+
|
|
26
26
|
#
|
|
27
|
-
def initialize(api, business_object_name,
|
|
27
|
+
def initialize(api, business_object_name, ordinal: nil)
|
|
28
28
|
@api = api
|
|
29
29
|
@business_object_name = business_object_name
|
|
30
|
-
@
|
|
30
|
+
@ordinal = ordinal
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Get a business object for the current member
|
|
@@ -84,7 +84,7 @@ module Usps
|
|
|
84
84
|
# @return [Hash] Response data from the API
|
|
85
85
|
#
|
|
86
86
|
def post(body)
|
|
87
|
-
request = Net::HTTP::Post.new(uri)
|
|
87
|
+
request = Net::HTTP::Post.new(uri(id: ''))
|
|
88
88
|
request.body = JSON.dump(body)
|
|
89
89
|
result = submit(uri, authorize(request))
|
|
90
90
|
JSON.parse(result.body)
|
|
@@ -107,12 +107,20 @@ module Usps
|
|
|
107
107
|
|
|
108
108
|
# Construct a business object API endpoint address
|
|
109
109
|
#
|
|
110
|
-
def uri
|
|
111
|
-
|
|
112
|
-
full_path = "#{API_PATH}/#{business_object_name}/#{id_for_url}"
|
|
110
|
+
def uri(id: nil)
|
|
111
|
+
full_path = "#{API_PATH}/#{business_object_name}/#{id_for_uri(id)}"
|
|
113
112
|
URI(File.join(Imis.configuration.hostname, full_path))
|
|
114
113
|
end
|
|
115
114
|
|
|
115
|
+
# Select the correct ID to use in the URI
|
|
116
|
+
#
|
|
117
|
+
def id_for_uri(id = nil)
|
|
118
|
+
return CGI.escape(id) unless id.nil?
|
|
119
|
+
return CGI.escape("~#{api.imis_id}|#{ordinal}") if ordinal
|
|
120
|
+
|
|
121
|
+
api.imis_id
|
|
122
|
+
end
|
|
123
|
+
|
|
116
124
|
# Manually assemble the matching data structure, with fields in the correct order
|
|
117
125
|
#
|
|
118
126
|
def filter_fields(fields)
|
|
@@ -20,7 +20,7 @@ module Usps
|
|
|
20
20
|
# @param ordinal [Integer] The ordinal identifier for the desired object
|
|
21
21
|
#
|
|
22
22
|
def get(ordinal)
|
|
23
|
-
api.
|
|
23
|
+
api.on(business_object, ordinal:).get
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Create a new object in the Panel
|
|
@@ -28,7 +28,7 @@ module Usps
|
|
|
28
28
|
# @param data [Hash] The record data for the desired object
|
|
29
29
|
#
|
|
30
30
|
def create(data)
|
|
31
|
-
api.
|
|
31
|
+
api.on(business_object).post(payload(data))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# Update an existing object in the Panel
|
|
@@ -37,9 +37,7 @@ module Usps
|
|
|
37
37
|
# +ordinal+ identifier
|
|
38
38
|
#
|
|
39
39
|
def update(data)
|
|
40
|
-
api
|
|
41
|
-
.business_object(business_object, url_id: "~#{api.imis_id}|#{data[:ordinal]}")
|
|
42
|
-
.put(payload(data))
|
|
40
|
+
api.on(business_object, ordinal: data[:ordinal]).put(payload(data))
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
# Remove a specific object from the Panel
|
|
@@ -47,7 +45,7 @@ module Usps
|
|
|
47
45
|
# @param ordinal [Integer] The ordinal identifier for the desired object
|
|
48
46
|
#
|
|
49
47
|
def destroy(ordinal)
|
|
50
|
-
api.
|
|
48
|
+
api.on(business_object, ordinal:).delete
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
private
|
data/lib/usps/imis/version.rb
CHANGED