oi-api-ruby 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ad2f7f3221907138a4088a35823cdabc4e0b0d6
4
- data.tar.gz: 23b51fc57c456786e6583ebccb5c26ac6dbbc710
3
+ metadata.gz: c1094fa30f14e4b926e704176430e89a48aadcd7
4
+ data.tar.gz: 5387b08c7d62d1c79cb8f1ad5ef8b9386bdad9e4
5
5
  SHA512:
6
- metadata.gz: bec6d0d80718c98cc1ba9fbcda27ae5c125d20705cc91eb0285c6667fc97a7baae4614642869d70d49aae1986338f5aec0f1372b878e81bf30d19219699ac9e9
7
- data.tar.gz: 07ed64a3648e1945ae743aa871d2579f2d4975ae8f300d5841f6e8be47fa3fbe0f6fcbd300b27988d5331b9d63bff635fc987f4fc2f72b9e6b2aaef7f7e361d2
6
+ metadata.gz: 5fe4276fc9dd95669e6989f55738d59df2840ee7d349d9e674b4f63038d266672cf6ff7f670c2f05e9ad0bfce09a3e8894086c89dc181207db68f5521fc16bc1
7
+ data.tar.gz: 78a78bdb819ab55831814c293624dd11181b490da8ab750ae22ae0bcb685a5a707629c5b71584bf752b692ad957a7b5d23a13dd9c3b100a2e0916376fa2b5425
@@ -18,25 +18,50 @@ module OiApi
18
18
  'Travel' => 1012,
19
19
  }
20
20
 
21
- DATA_POINTS = {
22
- FN: { dynamic_field_value: '#{FN}', description: 'First Name' },
23
- LN: { dynamic_field_value: '#{LN}', description: 'Last Name' },
24
- EM: { dynamic_field_value: '#{EM}', description: 'Email' },
25
- AD1: { dynamic_field_value: '#{AD1}', description: 'Street Address' },
26
- CI: { dynamic_field_value: '#{CI}', description: 'City' },
27
- ST: { dynamic_field_value: '#{ST}', description: 'State' },
28
- PO: { dynamic_field_value: '#{PO}', description: 'Postal Code' },
29
- CO: { dynamic_field_value: '#{CO}', description: 'Country' },
30
- HP: { dynamic_field_value: '#{HP}', description: 'Home Phone Number' },
31
- MP: { dynamic_field_value: '#{MP}', description: 'Mobile Phone Number' },
32
- G: { dynamic_field_value: '#{G}', description: 'Gender' },
33
- DOB: { dynamic_filed_value: '#{DOB}', description: 'Date of Birth' }
21
+ DATA_FIELDS = {
22
+ first_name: { value: 'FN', field_value: '#{FN}', description: 'First Name' },
23
+ last_name: { value: 'LN', field_value: '#{LN}', description: 'Last Name' },
24
+ email: { value: 'EM', field_value: '#{EM}', description: 'Email' },
25
+ street_address: { value: 'AD1', field_value: '#{AD1}', description: 'Street Address' },
26
+ city: { value: 'CI', field_value: '#{CI}', description: 'City' },
27
+ state: { value: 'ST', field_value: '#{ST}', description: 'State' },
28
+ postal_code: { value: 'PO', field_value: '#{PO}', description: 'Postal Code' },
29
+ country: { value: 'CO', field_value: '#{CO}', description: 'Country' },
30
+ home_phone: { value: 'HP', field_value: '#{HP}', description: 'Home Phone Number' },
31
+ mobile_phone: { value: 'MP', field_value: '#{MP}', description: 'Mobile Phone Number' },
32
+ gender: { value: 'G', field_value: '#{G}', description: 'Gender' },
33
+ date_of_birth: { value: 'DOB', field_value: '#{DOB}', description: 'Date of Birth' }
34
34
  }
35
35
 
36
- def category_names
36
+ def self.category_names
37
37
  CATEGORIES.keys
38
38
  end
39
39
 
40
+ def self.category_ids
41
+ CATEGORIES.values
42
+ end
43
+
44
+ # returns an array of hashes used when posting to OiApi
45
+ # to create a new data transfer. The resulting structure
46
+ # looks like:
47
+ # [
48
+ # { email: '#{EM}' },
49
+ # { first_name: '#{FN}' },
50
+ # { last_name: '#{LN}' },
51
+ # { zip: '#{PO}' },
52
+ # { gender: '#{G}' },
53
+ # ...
54
+ # ]
55
+ #
56
+ # This tells OiApi what attribute names to use when posting
57
+ # contacts back to our endpoint
58
+ #
59
+ def self.data_fields
60
+ OiApi::LookupTables::DATA_FIELDS.map do |data_point|
61
+ { data_point[0] => data_point[1][:field_value] }
62
+ end
63
+ end
64
+
40
65
  end
41
66
 
42
67
  end
@@ -1,3 +1,3 @@
1
1
  module OiApi
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe OiApi::LookupTables do
4
+
5
+ context 'data_fields' do
6
+
7
+ it 'returns the correct array of hashes' do
8
+ expect(OiApi::LookupTables.data_fields).to eql([
9
+ { first_name: '#{FN}'},
10
+ { last_name: '#{LN}'},
11
+ { email: '#{EM}'},
12
+ { street_address: '#{AD1}'},
13
+ { city: '#{CI}'},
14
+ { state: '#{ST}'},
15
+ { postal_code: '#{PO}'},
16
+ { country: '#{CO}'},
17
+ { home_phone: '#{HP}'},
18
+ { mobile_phone: '#{MP}'},
19
+ { gender: '#{G}'},
20
+ { date_of_birth: '#{DOB}'}
21
+ ])
22
+ end
23
+
24
+ end
25
+
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oi-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrod Spillers
@@ -290,6 +290,7 @@ files:
290
290
  - spec/oi_api/client/offers_spec.rb
291
291
  - spec/oi_api/client/reports_spec.rb
292
292
  - spec/oi_api/client/subscriptions_spec.rb
293
+ - spec/oi_api/lookup_tables_spec.rb
293
294
  - spec/oi_api_spec.rb
294
295
  - spec/shared_examples_for_delete_resource.rb
295
296
  - spec/shared_examples_for_get_resource.rb
@@ -469,6 +470,7 @@ test_files:
469
470
  - spec/oi_api/client/offers_spec.rb
470
471
  - spec/oi_api/client/reports_spec.rb
471
472
  - spec/oi_api/client/subscriptions_spec.rb
473
+ - spec/oi_api/lookup_tables_spec.rb
472
474
  - spec/oi_api_spec.rb
473
475
  - spec/shared_examples_for_delete_resource.rb
474
476
  - spec/shared_examples_for_get_resource.rb