cloudhub_wrapper 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/default.xml +13 -0
- data/lib/cloudhub_wrapper.rb +45 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9d6728340dfc9fab4d4073a0bebe313ff027cf
|
4
|
+
data.tar.gz: 6e577a7547456f848be36d4cd120ef731fea0149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5108ebce073cfe84661272945f15ffecb82276a5afe9a2b0641a52c6f03dad3984ae7a115c78176bcca3fda7fab3ed6c06b9a45951ca3df948f68e3b6b98ba32
|
7
|
+
data.tar.gz: f2bab3a9592c1627e3037722c3c2729a3ce92eb87cd0d661c834acad5ec4ba0bad83bf099bc2a2c7532ff82d5f5c1178d0526982e2b1186f55c1d23e25e46de3
|
data/data/default.xml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<ns0:accountInterchange interchangeControlNo='00000001' agreementName='SF.LE' senderQualifier='ZZ' senderId='LE' receiverQualifier='ZZ' receiverId='SF' interchangeDate='##time##' xmlns:ns0='##schema##'>
|
2
|
+
<ns0:account id='##email##' domain='external' type='Retail Account' creationDateTime='##time##' xmlns:ns0='##schema##'>
|
3
|
+
<ns0:address addressType='home'>
|
4
|
+
<ns0:country isoCountryCode='AU'>Australia</ns0:country>
|
5
|
+
</ns0:address>
|
6
|
+
<ns0:contact contactRole='requestor'>
|
7
|
+
<ns0:contactPreference contactVia='Email' contactOption='OptIn'/>
|
8
|
+
<ns0:channelContactPreferences>
|
9
|
+
<ns0:channelContactPreference channel='##channel##' contactOption='optIn' origin='##origin##'/>
|
10
|
+
</ns0:channelContactPreferences>
|
11
|
+
</ns0:contact>
|
12
|
+
</ns0:account>
|
13
|
+
</ns0:accountInterchange>
|
data/lib/cloudhub_wrapper.rb
CHANGED
@@ -2,6 +2,8 @@ class CloudhubWrapper
|
|
2
2
|
|
3
3
|
require "net/https"
|
4
4
|
require "uri"
|
5
|
+
require "rexml/document"
|
6
|
+
|
5
7
|
|
6
8
|
def initialize(endpoint, user, password)
|
7
9
|
@endpoint = endpoint
|
@@ -18,8 +20,49 @@ class CloudhubWrapper
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def build_xml(subscriber, channel, origin, schema)
|
21
|
-
|
22
|
-
|
23
|
+
address_elements = [
|
24
|
+
[:address, "addressLine"],
|
25
|
+
[:suburb, "suburb"],
|
26
|
+
[:postcode, "postalcode"],
|
27
|
+
[:post_code, "postalcode"],
|
28
|
+
[:state, "state"]
|
29
|
+
]
|
30
|
+
|
31
|
+
contact_elements = [
|
32
|
+
[:first_name, "firstName"],
|
33
|
+
[:last_name, "lastName"],
|
34
|
+
[:email, "email"],
|
35
|
+
[:mobile, "phone"],
|
36
|
+
[:phone, "phone"]
|
37
|
+
]
|
38
|
+
|
39
|
+
|
40
|
+
doc = REXML::Document.new(File.read("data/default.xml"))
|
41
|
+
root = doc.root
|
42
|
+
address_el = root.elements[1].elements["ns0:address"]
|
43
|
+
contact_el = root.elements[1].elements["ns0:contact"]
|
44
|
+
|
45
|
+
root.add_attributes({"interchangeDate" => Time.now.to_s, "xmlns:ns0" => schema})
|
46
|
+
root.elements["ns0:account"].add_attributes({"id" => subscriber.email, "creationDateTime" => Time.now.to_s, "xmlns:ns0" => schema})
|
47
|
+
contact_el.elements["ns0:channelContactPreferences"].children[1].add_attributes({"channel" => channel, "origin" => origin })
|
48
|
+
|
49
|
+
address_elements.each do |array|
|
50
|
+
if subscriber.respond_to? array[0]
|
51
|
+
el = REXML::Element.new("ns0:#{array[1]}", address_el)
|
52
|
+
el.add_text(subscriber.send(array[0]))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
contact_elements.each do |array|
|
57
|
+
if subscriber.respond_to? array[0]
|
58
|
+
el = REXML::Element.new("ns0:#{array[1]}", contact_el)
|
59
|
+
el.add_text(subscriber.send(array[0]))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
@xml = doc.to_s
|
65
|
+
|
23
66
|
end
|
24
67
|
|
25
68
|
def post_xml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudhub_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Froese
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- MIT-LICENSE
|
20
20
|
- README.md
|
21
|
+
- data/default.xml
|
21
22
|
- lib/cloudhub_wrapper.rb
|
22
23
|
homepage: http://rubygems.org/gems/cloudhub_wrapper
|
23
24
|
licenses:
|