silverpop 0.0.8 → 0.0.9

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
  SHA1:
3
- metadata.gz: d0cbf7fb5b1742d246ec1fc7c99a658934c02976
4
- data.tar.gz: 11120fe410729c6435173020423c209a3e7fc252
3
+ metadata.gz: 45f524f4b6b2ebf46c451d7a0bbf417fd6dcd87c
4
+ data.tar.gz: da1439794e0aed35c78f5b9340f701826e5503c6
5
5
  SHA512:
6
- metadata.gz: 2dd9822b4be36314bf889cf1570a255d7a39f818a66c0bc5d9ea7f61975816b2c7d2e1cff105fb20799230509dd7ab7c0da45ce0495e24b2637966244f25f8d8
7
- data.tar.gz: 1e71a3643a849f13181d65e909d3539b8999050b915853e19b77aa16ebc45cc4179c52a6eb8581b541461cdcc6fc3013809458f48acf2763502ea6d9f58f02d7
6
+ metadata.gz: b303e169d6e97ffcf05edd75d605499615d96f47150736067a1d2e88268c902b2b94d835039cb60610dec345702a25c90db4e3cbd75fd8ba351e65bb7f9130d5
7
+ data.tar.gz: 398052c50efb1b2bbb427b1824c0d3d6370c0189b568964c9e209d2905bbc1abaaf68df065ddf68b867db377d9c0ed8f2feec940166a73c7ccb49cd008e88c35
@@ -1,8 +1,9 @@
1
1
  bundler_args: --without development
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.2
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.0
8
- - 2.1.5
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ before_install:
9
+ - gem update bundler
data/Gemfile CHANGED
@@ -2,6 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
5
+ group :development, :test do
6
+ gem 'pry'
7
+ end
8
+
5
9
  group :test do
6
10
  gem 'rspec'
7
11
  gem 'simplecov', :require => false
@@ -37,7 +37,7 @@ module SilverPop
37
37
  }
38
38
  }
39
39
  }
40
- response = post(xml, options)
40
+ response = post(xml)
41
41
  end
42
42
 
43
43
  end
@@ -0,0 +1,66 @@
1
+ module SilverPop
2
+ class Client
3
+ module RelationalTable
4
+ # InsertUpdateRelationalTable - This interface inserts or updates relational data.
5
+ #
6
+ # @param table_id [String] Required parameter to specify the ID of the Relational Table you are interacting with. Either TABLE_NAME or TABLE_ID is required.
7
+ # @param rows [Array]
8
+ # @return [Mash] Mashify body from the API call
9
+ # @example Insert into table 86767 a row with one column
10
+ # s = SilverPop.new access_token: 'abc123', url: 'https://api1.silverpop.com'
11
+ # s.insert_update_relational_table '86767', [{'Record Id' => 'GHbjh73643hsdiy'}]
12
+ def insert_update_relational_table table_id, rows
13
+ builder = Builder::XmlMarkup.new
14
+
15
+ xml = builder.Envelope {
16
+ builder.Body {
17
+ builder.InsertUpdateRelationalTable {
18
+ builder.TABLE_ID table_id
19
+ builder.ROWS {
20
+ rows.each do |row|
21
+ builder.ROW {
22
+ row.each do |key, value|
23
+ builder.COLUMN(name: key) {
24
+ builder.cdata!(value)
25
+ }
26
+ end
27
+ }
28
+ end
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ post(xml)
35
+ end
36
+ end
37
+
38
+ # ExportTable - This interface supports programmatically exporting Relational Table data from Engage into a CSV file, which Engage uploads to the FTP account or to the Stored Files directory associated with the session.
39
+ #
40
+ # @param table_id [String] Optional parameter to specify the ID of the Relational Table you are exporting. Either TABLE_NAME or TABLE_ID is required.
41
+ # @param export_format [String] Specifies the format (file type) for the exported data, CSV, TAB, PIPE.
42
+ # @param options [Hash] Optional parameters to send
43
+ # @param export_colums [Array] XML node used to request specific custom database columns to export for each contact.
44
+ # @return [Mash] Mashify body from the API call
45
+ # @example Export Table 12345 for 1/1/2014 to 1/2/2014
46
+ # s = SilverPop.new({access_token: "abc123", url: "https://api1.silverpop.com"})
47
+ # s.export_table('12345', 'CSV', {DATE_START: "1/1/2014", DATE_END:"1/2/2014"})
48
+ def export_table(table_id, export_format, options={})
49
+ builder = Builder::XmlMarkup.new
50
+ xml = builder.Envelope {
51
+ builder.Body {
52
+ builder.ExportTable {
53
+ builder.TABLE_NAME table_id
54
+ builder.EXPORT_FORMAT export_format
55
+ unless options.empty?
56
+ options.each do |o|
57
+ builder.tag! o[0], o[1]
58
+ end
59
+ end
60
+ }
61
+ }
62
+ }
63
+ post(xml)
64
+ end
65
+ end
66
+ end
@@ -1,7 +1,6 @@
1
1
  module SilverPop
2
2
  class Client
3
3
  module User
4
-
5
4
  # ExportList - This interface exports contact data from a database, query, or contact list. Engage exports the results to a CSV file, then adds that file to the FTP account associated with the current session.
6
5
  #
7
6
  # @param list_id [String] Unique identifier for the database, query, or contact list Engage is exporting.
@@ -23,7 +22,7 @@ module SilverPop
23
22
  builder.EXPORT_FORMAT export_format
24
23
  unless options.empty?
25
24
  options.each do |o|
26
- builder.tag! o[0], o[1]
25
+ builder.tag! o[0], o[1]
27
26
  end
28
27
  end
29
28
  unless export_columns.empty?
@@ -38,37 +37,7 @@ module SilverPop
38
37
  }
39
38
  post(xml)
40
39
  end
41
-
42
- end
43
-
44
- # ExportTable - This interface supports programmatically exporting Relational Table data from Engage into a CSV file, which Engage uploads to the FTP account or to the Stored Files directory associated with the session.
45
- #
46
- # @param table_id [String] Optional parameter to specify the ID of the Relational Table you are exporting. Either TABLE_NAME or TABLE_ID is required.
47
- # @param export_format [String] Specifies the format (file type) for the exported data, CSV, TAB, PIPE.
48
- # @param options [Hash] Optional parameters to send
49
- # @param export_colums [Array] XML node used to request specific custom database columns to export for each contact.
50
- # @return [Mash] Mashify body from the API call
51
- # @example Export Table 12345 for 1/1/2014 to 1/2/2014
52
- # s = SilverPop.new({access_token: "abc123", url: "https://api1.silverpop.com"})
53
- # s.export_table('12345', 'CSV', {DATE_START: "1/1/2014", DATE_END:"1/2/2014"})
54
- def export_table(table_id, export_format, options={})
55
- builder = Builder::XmlMarkup.new
56
- xml = builder.Envelope {
57
- builder.Body {
58
- builder.ExportTable {
59
- builder.TABLE_NAME table_id
60
- builder.EXPORT_FORMAT export_format
61
- unless options.empty?
62
- options.each do |o|
63
- builder.tag! o[0], o[1]
64
- end
65
- end
66
- }
67
- }
68
- }
69
- post(xml)
70
40
  end
71
-
72
41
  end
73
42
  end
74
43
 
@@ -4,6 +4,7 @@ require 'silverpop/request'
4
4
  require 'client/contact'
5
5
  require 'client/reporting'
6
6
  require 'client/user'
7
+ require 'client/relational_table'
7
8
 
8
9
  module SilverPop
9
10
  class Client
@@ -17,5 +18,6 @@ module SilverPop
17
18
  include SilverPop::Client::Contact
18
19
  include SilverPop::Client::Reporting
19
20
  include SilverPop::Client::User
21
+ include SilverPop::Client::RelationalTable
20
22
  end
21
23
  end
@@ -1,7 +1,7 @@
1
1
  module SilverPop
2
2
  module Request
3
- def post(path, options={})
4
- request(:post, path, options)
3
+ def post(body)
4
+ request(:post, body)
5
5
  end
6
6
 
7
7
  private
@@ -10,7 +10,7 @@ module SilverPop
10
10
  #
11
11
  # @param body [String] The formatted XML of the API call make sure to call builder.to_xml.
12
12
  # @return [XML] XML Body from the API call
13
- def request(method, body, options)
13
+ def request(method, body)
14
14
  response = connection.send(method) do |request|
15
15
  request.url "/XMLAPI"
16
16
  request.headers['Content-type'] = "text/xml"
@@ -1,3 +1,3 @@
1
1
  module SilverPop
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ describe SilverPop::Client::RelationalTable do
4
+ before do
5
+ @client = SilverPop.new access_token: 'abc123', url: 'https://api1.silverpop.com'
6
+ end
7
+
8
+ describe '.insert_update_relational_table' do
9
+ it 'returns the success as true' do
10
+ stub_post('/XMLAPI?access_token=abc123')
11
+ .with(body: '<Envelope><Body><InsertUpdateRelationalTable><TABLE_ID>86767</TABLE_ID><ROWS><ROW><COLUMN name="Record Id"><![CDATA[GHbjh73643hsdiy]]></COLUMN></ROW></ROWS></InsertUpdateRelationalTable></Body></Envelope>')
12
+ .to_return status: 200,
13
+ body: fixture('relational_table.xml'),
14
+ headers: { 'Content-type' => 'text/xml' }
15
+
16
+ resp = @client.insert_update_relational_table '86767', [{'Record Id' => 'GHbjh73643hsdiy'}]
17
+
18
+ expect(resp.Envelope.Body.RESULT.SUCCESS).to eq('true')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ <Envelope>
2
+ <Body>
3
+ <RESULT>
4
+ <SUCCESS>true</SUCCESS>
5
+ </RESULT>
6
+ </Body>
7
+ </Envelope>
@@ -7,6 +7,7 @@ end
7
7
  require 'silverpop'
8
8
  require 'rspec'
9
9
  require 'webmock/rspec'
10
+ require 'pry'
10
11
 
11
12
  def stub_post(url)
12
13
  stub_request(:post, silverpop_url(url))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silverpop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Upworthy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -152,6 +152,7 @@ files:
152
152
  - README.md
153
153
  - Rakefile
154
154
  - lib/client/contact.rb
155
+ - lib/client/relational_table.rb
155
156
  - lib/client/reporting.rb
156
157
  - lib/client/user.rb
157
158
  - lib/silverpop.rb
@@ -161,9 +162,11 @@ files:
161
162
  - lib/silverpop/version.rb
162
163
  - silverpop.gemspec
163
164
  - spec/client/contact_spec.rb
165
+ - spec/client/relational_table_spec.rb
164
166
  - spec/client/reporting_spec.rb
165
167
  - spec/client/user_spec.rb
166
168
  - spec/fixtures/contact.xml
169
+ - spec/fixtures/relational_table.xml
167
170
  - spec/fixtures/reporting.xml
168
171
  - spec/fixtures/sent_mailings_org.xml
169
172
  - spec/helper.rb
@@ -194,11 +197,12 @@ specification_version: 4
194
197
  summary: A Ruby wrapper for the SilverPop API
195
198
  test_files:
196
199
  - spec/client/contact_spec.rb
200
+ - spec/client/relational_table_spec.rb
197
201
  - spec/client/reporting_spec.rb
198
202
  - spec/client/user_spec.rb
199
203
  - spec/fixtures/contact.xml
204
+ - spec/fixtures/relational_table.xml
200
205
  - spec/fixtures/reporting.xml
201
206
  - spec/fixtures/sent_mailings_org.xml
202
207
  - spec/helper.rb
203
208
  - spec/silverpop_spec.rb
204
- has_rdoc: