usps-imis-api 0.6.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cbe7660dffdee043ffdbe92a012879ceb439946b737f34fe9ca16d6f34e68b1
4
- data.tar.gz: 065c486f386c7b73501dda6bf92a0214680e3ab13104388de29613d4bb4d7315
3
+ metadata.gz: a7e57bee906686721fa8b760f9fa322e04b289087e9295713283a2f6fcd5d3e6
4
+ data.tar.gz: 6fe2a0b3405ddf20825ae24bb8986bf4e941a5fb46e37944988047faa5eb54e4
5
5
  SHA512:
6
- metadata.gz: 67e8a5cf1cb919bccaada7960f1680426491880340f68eb8ed3ed57e5922bfdd6ab98208534367679aaec6b0026c1afb8161e5df73c7fd1dff383293882239b7
7
- data.tar.gz: 830f0e96d1528bd434a4122511ab15165d27ef42f0383713e10640906395d19742e49b5da8858021fa3a2dbd64be699c5adf2c08f4897a5c3d6b94f8bb3d270f
6
+ metadata.gz: e635a0d05fb1ce0139b422be14d01de9118bc2fa7474ee63eb802c5671a793e4628eea5d320ca93c59c41807419089243e6f1bd3bbc87dbda6c1baee2f06d28c
7
+ data.tar.gz: a098bb43500c8db276cf03dd8b5f09954431b4a6011c6672656f061d05ca600972e70bab15ddd90877b62cedabb24f73d33575ea4ef5c6ef21d72e133f837cf7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.1)
4
+ usps-imis-api (0.6.2)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -40,6 +40,19 @@ module Usps
40
40
  JSON.parse(result.body)
41
41
  end
42
42
 
43
+ # Get a single named field from a business object for the current member
44
+ #
45
+ # @param name [String] Field name to return
46
+ #
47
+ # @return [Hash] Response data from the API
48
+ #
49
+ def get_field(name)
50
+ values = get['Properties']['$values']
51
+ value = values.find { |hash| hash['Name'] == name }['Value']
52
+
53
+ value.is_a?(String) ? value : value['$value']
54
+ end
55
+
43
56
  # Update only specific fields on a business object for the current member
44
57
  #
45
58
  # @param fields [Hash] Conforms to pattern +{ field_key => value }+
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.1'
5
+ VERSION = '0.6.2'
6
6
  end
7
7
  end
@@ -6,31 +6,41 @@ describe Usps::Imis::BusinessObject do
6
6
  let(:business_object) { described_class.new(api, 'Stub') }
7
7
  let(:api) { Usps::Imis::Api.new }
8
8
 
9
- describe '#filter_fields' do
10
- let(:expected) do
11
- {
12
- 'Properties' => {
13
- '$values' => [
14
- { 'Name' => 'Stub iMIS ID', 'Value' => { '$value' => '31092' } },
15
- { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
16
- { 'Name' => 'Stub String', 'Value' => 'other' }
17
- ]
18
- }
9
+ let(:expected) do
10
+ {
11
+ 'Properties' => {
12
+ '$values' => [
13
+ { 'Name' => 'Stub iMIS ID', 'Value' => { '$value' => '31092' } },
14
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 43 } },
15
+ { 'Name' => 'Stub String', 'Value' => 'other' }
16
+ ]
17
+ }
18
+ }
19
+ end
20
+
21
+ before do
22
+ allow(business_object).to receive(:get).and_return({
23
+ 'Properties' => {
24
+ '$values' => [
25
+ { 'Name' => 'Stub iMIS ID', 'Value' => { '$value' => '31092' } },
26
+ { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
27
+ { 'Name' => 'Stub String', 'Value' => 'something' }
28
+ ]
19
29
  }
30
+ })
31
+ end
32
+
33
+ describe '#get_field' do
34
+ it 'returns a string value' do
35
+ expect(business_object.get_field('Stub String')).to eq('something')
20
36
  end
21
37
 
22
- before do
23
- allow(business_object).to receive(:get).and_return({
24
- 'Properties' => {
25
- '$values' => [
26
- { 'Name' => 'Stub iMIS ID', 'Value' => { '$value' => '31092' } },
27
- { 'Name' => 'Stub Integer', 'Value' => { '$value' => 42 } },
28
- { 'Name' => 'Stub String', 'Value' => 'something' }
29
- ]
30
- }
31
- })
38
+ it 'returns an integer value' do
39
+ expect(business_object.get_field('Stub Integer')).to eq(42)
32
40
  end
41
+ end
33
42
 
43
+ describe '#filter_fields' do
34
44
  it 'formats fields correctly' do
35
45
  updated = business_object.send(:filter_fields, 'Stub Integer' => 43, 'Stub String' => 'other')
36
46
 
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander