sekken 0.1.0 → 0.2.0

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: 618f8169fb6022ee3b52de75d6900ef9cf53d5e3
4
- data.tar.gz: 5f2125e6801af9ca196819a9cbf6dcda95821d38
3
+ metadata.gz: 113a2291ad7a1beeb56e9cc689fb64e0e8981b12
4
+ data.tar.gz: 6eaa38a8ff63c9a0658a11a9a45af007c063bf42
5
5
  SHA512:
6
- metadata.gz: c3325dae933d2797fedfe1ca11edbd9c3e93cc8f5d1c88146132c95192bfdcc4e86d83e21cebbf8ac077f5ceba30805650fca3a9deb748fea6aed62a62db0373
7
- data.tar.gz: 854878b073807be0b43489afa41db1d858a3e623ad681f4f4ede59b92eb9370401285abc7c3eb3045bc62f9081350e224c53967e3b619d823109a8de417eb0fd
6
+ metadata.gz: 278a43d288ddfe7b88be45f7e38cc2ff91b7e2a0253cb869caa4fd8bf43431039721b06eb0a08bfaf8752c7c5533553c3e30d0ac833c70c8a6030a638b525910
7
+ data.tar.gz: a4979836de3440b806cf7ffb92e4d70a0ce7703f5886ae656c08b1a81382c93005c03439ea6e955a955aa7a4f53a8b6eea6e48f2e92819a55e98c412f80329c7
@@ -5,7 +5,11 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0
8
- - jruby-19mode
8
+ - jruby-head
9
9
  - rbx
10
10
  notifications:
11
11
  irc: "irc.freenode.org#savon"
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: jruby-head
@@ -0,0 +1,3 @@
1
+ # 0.2.0 (2014-05-05)
2
+
3
+ * Fix: [#8](https://github.com/savonrb/sekken/issue/8) Cache result of `Operation.build` so the result does not change after multiple invocations
data/Gemfile CHANGED
@@ -24,4 +24,5 @@ end
24
24
 
25
25
  group :development do
26
26
  gem 'fuubar'
27
+ gem 'pry'
27
28
  end
data/README.md CHANGED
@@ -21,8 +21,8 @@ Sekken is still in a very early stage, but [there is some documentation!](http:/
21
21
  ## Give back
22
22
 
23
23
  If you're using Sekken and you or your company is making money from it, then please consider
24
- donating via [Gittip](https://www.gittip.com/rubiii/) so that I can continue to improve it.
24
+ donating via [Gittip](https://www.gittip.com/tjarratt/) so that I can continue to improve it.
25
25
 
26
- [![donate](donate.png)](https://www.gittip.com/rubiii/)
26
+ [![donate](donate.png)](https://www.gittip.com/tjarratt/)
27
27
 
28
28
  Donate icon from the [Noun Project](http://thenounproject.com/noun/donate/#icon-No285).
@@ -66,9 +66,9 @@ class Sekken
66
66
  # Private: Raises if the operation style is not supported.
67
67
  def verify_operation_style!(operation)
68
68
  if operation.input_style == 'rpc/encoded'
69
- raise UnsupportedStyleError,
70
- "#{operation.name.inspect} is an #{operation.input_style.inspect} style operation.\n" \
71
- "Currently this style is not supported."
69
+ raise UnsupportedStyleError,
70
+ "#{operation.name.inspect} is an #{operation.input_style.inspect} style operation.\n" \
71
+ "Currently this style is not supported."
72
72
  end
73
73
  end
74
74
 
@@ -58,7 +58,13 @@ class Sekken
58
58
  end
59
59
  if value.is_a? Hash
60
60
  attributes, value = extract_attributes(value)
61
- xml.tag! *tag, value[tag[1]], attributes
61
+ if attributes.empty? && tag[1].nil?
62
+ t = xml.tag! *tag, {} do |b|
63
+ build_from_hash(b, value, xml)
64
+ end
65
+ else
66
+ xml.tag! *tag, value[tag[1]], attributes
67
+ end
62
68
  else
63
69
  xml.tag! *tag, value
64
70
  end
@@ -73,6 +79,22 @@ class Sekken
73
79
  end
74
80
  end
75
81
 
82
+ # build_from_hash 'foo', {a: {b: c: 123}}, xml
83
+ #
84
+ # => <foo><a><b><c>123</c></b></a></foo>
85
+ #
86
+ def build_from_hash(key, value, xml)
87
+ value.each do |k, v|
88
+ if v.is_a? Hash
89
+ key.tag!(k) do |nested|
90
+ build_from_hash(nested, v, xml)
91
+ end
92
+ else
93
+ key.tag! k, v
94
+ end
95
+ end
96
+ end
97
+
76
98
  def build_complex_type_element(element, xml, tag, value)
77
99
  if element.singular?
78
100
  unless value.kind_of? Hash
@@ -99,8 +121,18 @@ class Sekken
99
121
  xml.tag! *tag, attributes do |xml|
100
122
  build_elements(children, value, xml)
101
123
  end
102
- elsif value && value[tag[1]]
103
- xml.tag! *tag, value[tag[1]], attributes
124
+ elsif value
125
+ if value.is_a? Hash
126
+ if attributes.empty? && tag[1].nil?
127
+ t=xml.tag!(*tag) do |b|
128
+ build_from_hash(b, value, xml)
129
+ end
130
+ else
131
+ xml.tag! *tag, tag[1] ? value[tag[1]] : value, attributes
132
+ end
133
+ else
134
+ xml.tag! *tag, value
135
+ end
104
136
  else
105
137
  xml.tag! *tag, attributes
106
138
  end
@@ -8,8 +8,8 @@ class Sekken
8
8
  ENCODING = 'UTF-8'
9
9
 
10
10
  CONTENT_TYPE = {
11
- '1.1' => 'text/xml;charset=%s',
12
- '1.2' => 'application/soap+xml;charset=%s'
11
+ '1.1' => 'text/xml',
12
+ '1.2' => 'application/soap+xml'
13
13
  }
14
14
 
15
15
  def initialize(operation, wsdl, http)
@@ -39,9 +39,16 @@ class Sekken
39
39
  def http_headers
40
40
  return @http_headers if @http_headers
41
41
  headers = {}
42
+ content_type = [ CONTENT_TYPE[soap_version], "charset=#{encoding}" ]
42
43
 
43
- headers['SOAPAction'] = %{"#{soap_action}"} if soap_action
44
- headers['Content-Type'] = CONTENT_TYPE[soap_version] % encoding
44
+ case soap_version
45
+ when '1.1'
46
+ headers['SOAPAction'] = soap_action.nil? ? '' : %{"#{soap_action}"}
47
+ when '1.2'
48
+ content_type << %{action="#{soap_action}"} if soap_action && !soap_action.empty?
49
+ end
50
+
51
+ headers['Content-Type'] = content_type.join(';')
45
52
 
46
53
  @http_headers = headers
47
54
  end
@@ -72,7 +79,7 @@ class Sekken
72
79
 
73
80
  # Public: Build the request XML for this operation.
74
81
  def build
75
- Envelope.new(@operation, header, body).to_s
82
+ @build ||= Envelope.new(@operation, header, body).to_s
76
83
  end
77
84
 
78
85
  # Public: Sets the request envelope XML. Use in place of body().
@@ -1,5 +1,5 @@
1
1
  class Sekken
2
2
 
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
 
5
5
  end
@@ -111,7 +111,7 @@ class Sekken
111
111
  attr_reader :type, :ref
112
112
 
113
113
  def inline_type
114
- children.first
114
+ children.detect{|child| child.node.node_name.downcase != 'annotation' }
115
115
  end
116
116
 
117
117
  end
@@ -0,0 +1,403 @@
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl" href="http://api.daisycon.com/wsdlviewer.xsl" ?>
3
+ <definitions name="transaction" targetNamespace="http://api.daisycon.com/advertiser/soap//transaction/"
4
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
5
+ xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
6
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
7
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
8
+ xmlns:tns="http://api.daisycon.com/advertiser/soap//transaction/"
9
+ >
10
+ <types>
11
+ <xsd:schema targetNamespace="http://api.daisycon.com/advertiser/soap//transaction/">
12
+ <xsd:simpleType name="orderFieldsDirection">
13
+ <xsd:restriction base="xsd:string">
14
+ <xsd:enumeration value="ASCENDING" />
15
+ <xsd:enumeration value="DESCENDING" />
16
+ </xsd:restriction>
17
+ </xsd:simpleType>
18
+ <xsd:complexType name="orderFields">
19
+ <xsd:all>
20
+ <xsd:element name="field" type="xsd:string" />
21
+ <xsd:element name="direction" type="tns:orderFieldsDirection" />
22
+ </xsd:all>
23
+ </xsd:complexType>
24
+ <xsd:complexType name="ArrayOfOrderfields">
25
+ <xsd:complexContent>
26
+ <xsd:restriction base="soap-enc:Array">
27
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:orderFields[]" />
28
+ </xsd:restriction>
29
+ </xsd:complexContent>
30
+ </xsd:complexType>
31
+ <xsd:complexType name="ArrayOfString">
32
+ <xsd:complexContent>
33
+ <xsd:restriction base="soap-enc:Array">
34
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:string[]" />
35
+ </xsd:restriction>
36
+ </xsd:complexContent>
37
+ </xsd:complexType>
38
+ <xsd:complexType name="ArrayOfInt">
39
+ <xsd:complexContent>
40
+ <xsd:restriction base="soap-enc:Array">
41
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:int[]" />
42
+ </xsd:restriction>
43
+ </xsd:complexContent>
44
+ </xsd:complexType>
45
+ <xsd:simpleType name="transactionsFilterGender">
46
+ <xsd:restriction base="xsd:string">
47
+ <xsd:enumeration value="male" />
48
+ <xsd:enumeration value="female" />
49
+ <xsd:enumeration value="unknown" />
50
+ </xsd:restriction>
51
+ </xsd:simpleType>
52
+ <xsd:complexType name="ArrayOfTransactionsFilterGender">
53
+ <xsd:complexContent>
54
+ <xsd:restriction base="soap-enc:Array">
55
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionsFilterGender[]" />
56
+ </xsd:restriction>
57
+ </xsd:complexContent>
58
+ </xsd:complexType>
59
+ <xsd:simpleType name="transactionsFilterMediatype">
60
+ <xsd:restriction base="xsd:string">
61
+ <xsd:enumeration value="website" />
62
+ <xsd:enumeration value="keyword_marketing" />
63
+ <xsd:enumeration value="email_marketing" />
64
+ <xsd:enumeration value="socialmedia" />
65
+ <xsd:enumeration value="cashback" />
66
+ </xsd:restriction>
67
+ </xsd:simpleType>
68
+ <xsd:complexType name="ArrayOfTransactionsFilterMediatype">
69
+ <xsd:complexContent>
70
+ <xsd:restriction base="soap-enc:Array">
71
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionsFilterMediatype[]" />
72
+ </xsd:restriction>
73
+ </xsd:complexContent>
74
+ </xsd:complexType>
75
+ <xsd:simpleType name="transactionsFilterProvince">
76
+ <xsd:restriction base="xsd:string">
77
+ <xsd:enumeration value="unknown" />
78
+ <xsd:enumeration value="DR" />
79
+ <xsd:enumeration value="FL" />
80
+ <xsd:enumeration value="FR" />
81
+ <xsd:enumeration value="GE" />
82
+ <xsd:enumeration value="GR" />
83
+ <xsd:enumeration value="LI" />
84
+ <xsd:enumeration value="NH" />
85
+ <xsd:enumeration value="NB" />
86
+ <xsd:enumeration value="OV" />
87
+ <xsd:enumeration value="UT" />
88
+ <xsd:enumeration value="ZE" />
89
+ <xsd:enumeration value="ZH" />
90
+ </xsd:restriction>
91
+ </xsd:simpleType>
92
+ <xsd:complexType name="ArrayOfTransactionsFilterProvince">
93
+ <xsd:complexContent>
94
+ <xsd:restriction base="soap-enc:Array">
95
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionsFilterProvince[]" />
96
+ </xsd:restriction>
97
+ </xsd:complexContent>
98
+ </xsd:complexType>
99
+ <xsd:simpleType name="transactionsFilterStatus">
100
+ <xsd:restriction base="xsd:string">
101
+ <xsd:enumeration value="open" />
102
+ <xsd:enumeration value="approved" />
103
+ <xsd:enumeration value="disapproved" />
104
+ </xsd:restriction>
105
+ </xsd:simpleType>
106
+ <xsd:complexType name="ArrayOfTransactionsFilterStatus">
107
+ <xsd:complexContent>
108
+ <xsd:restriction base="soap-enc:Array">
109
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionsFilterStatus[]" />
110
+ </xsd:restriction>
111
+ </xsd:complexContent>
112
+ </xsd:complexType>
113
+ <xsd:complexType name="transactionsFilter">
114
+ <xsd:all>
115
+ <xsd:element name="offset" type="xsd:int" nillable="true" />
116
+ <xsd:element name="limitCount" type="xsd:int" nillable="true" />
117
+ <xsd:element name="orderBy" type="tns:ArrayOfOrderfields" nillable="true" />
118
+ <xsd:element name="affiliatemarketing_id" type="tns:ArrayOfString" nillable="true" />
119
+ <xsd:element name="selection_start" type="xsd:date" maxOccurs="1" minOccurs="1" />
120
+ <xsd:element name="selection_end" type="xsd:date" maxOccurs="1" minOccurs="1" />
121
+ <xsd:element name="by_mutation" type="xsd:boolean" nillable="true" />
122
+ <xsd:element name="program_ids" type="tns:ArrayOfInt" nillable="true" />
123
+ <xsd:element name="advertiser_ids" type="tns:ArrayOfInt" />
124
+ <xsd:element name="media_ids" type="tns:ArrayOfInt" nillable="true" />
125
+ <xsd:element name="gender" type="tns:ArrayOfTransactionsFilterGender" nillable="true" />
126
+ <xsd:element name="description" type="xsd:string" nillable="true" />
127
+ <xsd:element name="mediatype" type="tns:ArrayOfTransactionsFilterMediatype" nillable="true" />
128
+ <xsd:element name="extra1" type="xsd:string" nillable="true" />
129
+ <xsd:element name="extra2" type="xsd:string" nillable="true" />
130
+ <xsd:element name="extra3" type="xsd:string" nillable="true" />
131
+ <xsd:element name="extra4" type="xsd:string" nillable="true" />
132
+ <xsd:element name="extra5" type="xsd:string" nillable="true" />
133
+ <xsd:element name="program_tag" type="xsd:string" nillable="true" />
134
+ <xsd:element name="province" type="tns:ArrayOfTransactionsFilterProvince" nillable="true" />
135
+ <xsd:element name="status" type="tns:ArrayOfTransactionsFilterStatus" nillable="true" />
136
+ </xsd:all>
137
+ </xsd:complexType>
138
+ <xsd:simpleType name="transactionCurrency">
139
+ <xsd:restriction base="xsd:string">
140
+ <xsd:enumeration value="EUR" />
141
+ </xsd:restriction>
142
+ </xsd:simpleType>
143
+ <xsd:simpleType name="transactionStatus">
144
+ <xsd:restriction base="xsd:string">
145
+ <xsd:enumeration value="open" />
146
+ <xsd:enumeration value="approved" />
147
+ <xsd:enumeration value="disapproved" />
148
+ </xsd:restriction>
149
+ </xsd:simpleType>
150
+ <xsd:simpleType name="transactionProvince">
151
+ <xsd:restriction base="xsd:string">
152
+ <xsd:enumeration value="unknown" />
153
+ <xsd:enumeration value="DR" />
154
+ <xsd:enumeration value="FL" />
155
+ <xsd:enumeration value="FR" />
156
+ <xsd:enumeration value="GE" />
157
+ <xsd:enumeration value="GR" />
158
+ <xsd:enumeration value="LI" />
159
+ <xsd:enumeration value="NH" />
160
+ <xsd:enumeration value="NB" />
161
+ <xsd:enumeration value="OV" />
162
+ <xsd:enumeration value="UT" />
163
+ <xsd:enumeration value="ZE" />
164
+ <xsd:enumeration value="ZH" />
165
+ </xsd:restriction>
166
+ </xsd:simpleType>
167
+ <xsd:complexType name="ArrayOfTransactionProvince">
168
+ <xsd:complexContent>
169
+ <xsd:restriction base="soap-enc:Array">
170
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionProvince[]" />
171
+ </xsd:restriction>
172
+ </xsd:complexContent>
173
+ </xsd:complexType>
174
+ <xsd:simpleType name="transactionGender">
175
+ <xsd:restriction base="xsd:string">
176
+ <xsd:enumeration value="male" />
177
+ <xsd:enumeration value="female" />
178
+ <xsd:enumeration value="unknown" />
179
+ </xsd:restriction>
180
+ </xsd:simpleType>
181
+ <xsd:complexType name="ArrayOfTransactionGender">
182
+ <xsd:complexContent>
183
+ <xsd:restriction base="soap-enc:Array">
184
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transactionGender[]" />
185
+ </xsd:restriction>
186
+ </xsd:complexContent>
187
+ </xsd:complexType>
188
+ <xsd:complexType name="transaction">
189
+ <xsd:all>
190
+ <xsd:element name="affiliatemarketing_id" type="xsd:string" nillable="true" />
191
+ <xsd:element name="date_transaction" type="xsd:dateTime" maxOccurs="1" minOccurs="1" />
192
+ <xsd:element name="date_click" type="xsd:dateTime" maxOccurs="1" minOccurs="1" />
193
+ <xsd:element name="advertiser_id" type="xsd:int" nillable="true" />
194
+ <xsd:element name="publisher_id" type="xsd:int" nillable="true" />
195
+ <xsd:element name="media_id" type="xsd:int" nillable="true" />
196
+ <xsd:element name="media_name" type="xsd:string" nillable="true" />
197
+ <xsd:element name="program_id" type="xsd:int" nillable="true" />
198
+ <xsd:element name="program_name" type="xsd:string" nillable="true" />
199
+ <xsd:element name="adgroup_id" type="xsd:int" nillable="true" />
200
+ <xsd:element name="ad_id" type="xsd:int" nillable="true" />
201
+ <xsd:element name="commission" type="xsd:float" nillable="true" />
202
+ <xsd:element name="currency" type="tns:transactionCurrency" />
203
+ <xsd:element name="program_description" type="xsd:string" nillable="true" />
204
+ <xsd:element name="program_tag" type="xsd:string" nillable="true" />
205
+ <xsd:element name="ip" type="xsd:string" nillable="true" />
206
+ <xsd:element name="referer" type="xsd:string" nillable="true" />
207
+ <xsd:element name="status" type="tns:transactionStatus" nillable="true" />
208
+ <xsd:element name="disapprove_reason" type="xsd:string" nillable="true" />
209
+ <xsd:element name="approval_date" type="xsd:dateTime" maxOccurs="1" nillable="true" />
210
+ <xsd:element name="last_modified" type="xsd:dateTime" maxOccurs="1" nillable="true" />
211
+ <xsd:element name="country_id" type="xsd:int" nillable="true" />
212
+ <xsd:element name="country_code" type="xsd:string" nillable="true" />
213
+ <xsd:element name="province" type="tns:ArrayOfTransactionProvince" nillable="true" />
214
+ <xsd:element name="gender" type="tns:ArrayOfTransactionGender" nillable="true" />
215
+ <xsd:element name="birthday" type="xsd:dateTime" maxOccurs="1" nillable="true" />
216
+ <xsd:element name="revenue" type="xsd:float" nillable="true" />
217
+ <xsd:element name="extra1" type="xsd:string" nillable="true" />
218
+ <xsd:element name="extra2" type="xsd:string" nillable="true" />
219
+ <xsd:element name="extra3" type="xsd:string" nillable="true" />
220
+ <xsd:element name="extra4" type="xsd:string" nillable="true" />
221
+ <xsd:element name="extra5" type="xsd:string" nillable="true" />
222
+ </xsd:all>
223
+ </xsd:complexType>
224
+ <xsd:complexType name="ArrayOfTransaction">
225
+ <xsd:complexContent>
226
+ <xsd:restriction base="soap-enc:Array">
227
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:transaction[]" />
228
+ </xsd:restriction>
229
+ </xsd:complexContent>
230
+ </xsd:complexType>
231
+ <xsd:simpleType name="validate_transactionStatus">
232
+ <xsd:restriction base="xsd:string">
233
+ <xsd:enumeration value="open" />
234
+ <xsd:enumeration value="approved" />
235
+ <xsd:enumeration value="disapproved" />
236
+ </xsd:restriction>
237
+ </xsd:simpleType>
238
+ <xsd:simpleType name="validate_transactionDisapprove_reason">
239
+ <xsd:restriction base="xsd:string">
240
+ <xsd:enumeration value="invalid" />
241
+ <xsd:enumeration value="duplicate" />
242
+ <xsd:enumeration value="cancelled" />
243
+ <xsd:enumeration value="nopayment" />
244
+ <xsd:enumeration value="refunded" />
245
+ <xsd:enumeration value="testorder" />
246
+ </xsd:restriction>
247
+ </xsd:simpleType>
248
+ <xsd:complexType name="validate_transaction">
249
+ <xsd:all>
250
+ <xsd:element name="program_id" type="xsd:int" />
251
+ <xsd:element name="affiliatemarketing_id" type="xsd:string" nillable="true" />
252
+ <xsd:element name="program_tag" type="xsd:string" nillable="true" />
253
+ <xsd:element name="commission" type="xsd:float" nillable="true" />
254
+ <xsd:element name="status" type="tns:validate_transactionStatus" nillable="true" />
255
+ <xsd:element name="disapprove_reason" type="tns:validate_transactionDisapprove_reason" nillable="true" />
256
+ </xsd:all>
257
+ </xsd:complexType>
258
+ <xsd:complexType name="ArrayOfValidate_transaction">
259
+ <xsd:complexContent>
260
+ <xsd:restriction base="soap-enc:Array">
261
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:validate_transaction[]" />
262
+ </xsd:restriction>
263
+ </xsd:complexContent>
264
+ </xsd:complexType>
265
+ <xsd:simpleType name="successesStatus">
266
+ <xsd:restriction base="xsd:string">
267
+ <xsd:enumeration value="open" />
268
+ <xsd:enumeration value="approved" />
269
+ <xsd:enumeration value="disapproved" />
270
+ </xsd:restriction>
271
+ </xsd:simpleType>
272
+ <xsd:simpleType name="successesDisapprove_reason">
273
+ <xsd:restriction base="xsd:string">
274
+ <xsd:enumeration value="invalid" />
275
+ <xsd:enumeration value="duplicate" />
276
+ <xsd:enumeration value="cancelled" />
277
+ <xsd:enumeration value="nopayment" />
278
+ <xsd:enumeration value="refunded" />
279
+ <xsd:enumeration value="testorder" />
280
+ </xsd:restriction>
281
+ </xsd:simpleType>
282
+ <xsd:complexType name="successes">
283
+ <xsd:all>
284
+ <xsd:element name="program_id" type="xsd:int" />
285
+ <xsd:element name="affiliatemarketing_id" type="xsd:string" nillable="true" />
286
+ <xsd:element name="program_tag" type="xsd:string" nillable="true" />
287
+ <xsd:element name="commission" type="xsd:float" nillable="true" />
288
+ <xsd:element name="status" type="tns:successesStatus" nillable="true" />
289
+ <xsd:element name="disapprove_reason" type="tns:successesDisapprove_reason" nillable="true" />
290
+ </xsd:all>
291
+ </xsd:complexType>
292
+ <xsd:complexType name="ArrayOfSuccesses">
293
+ <xsd:complexContent>
294
+ <xsd:restriction base="soap-enc:Array">
295
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:successes[]" />
296
+ </xsd:restriction>
297
+ </xsd:complexContent>
298
+ </xsd:complexType>
299
+ <xsd:simpleType name="failuresStatus">
300
+ <xsd:restriction base="xsd:string">
301
+ <xsd:enumeration value="open" />
302
+ <xsd:enumeration value="approved" />
303
+ <xsd:enumeration value="disapproved" />
304
+ </xsd:restriction>
305
+ </xsd:simpleType>
306
+ <xsd:simpleType name="failuresDisapprove_reason">
307
+ <xsd:restriction base="xsd:string">
308
+ <xsd:enumeration value="invalid" />
309
+ <xsd:enumeration value="duplicate" />
310
+ <xsd:enumeration value="cancelled" />
311
+ <xsd:enumeration value="nopayment" />
312
+ <xsd:enumeration value="refunded" />
313
+ <xsd:enumeration value="testorder" />
314
+ </xsd:restriction>
315
+ </xsd:simpleType>
316
+ <xsd:complexType name="failures">
317
+ <xsd:all>
318
+ <xsd:element name="program_id" type="xsd:int" />
319
+ <xsd:element name="affiliatemarketing_id" type="xsd:string" nillable="true" />
320
+ <xsd:element name="program_tag" type="xsd:string" nillable="true" />
321
+ <xsd:element name="commission" type="xsd:float" nillable="true" />
322
+ <xsd:element name="status" type="tns:failuresStatus" nillable="true" />
323
+ <xsd:element name="disapprove_reason" type="tns:failuresDisapprove_reason" nillable="true" />
324
+ <xsd:element name="error" type="xsd:string" nillable="true" />
325
+ </xsd:all>
326
+ </xsd:complexType>
327
+ <xsd:complexType name="ArrayOfFailures">
328
+ <xsd:complexContent>
329
+ <xsd:restriction base="soap-enc:Array">
330
+ <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:failures[]" />
331
+ </xsd:restriction>
332
+ </xsd:complexContent>
333
+ </xsd:complexType>
334
+ <xsd:complexType name="validatedTransactionReturn">
335
+ <xsd:all>
336
+ <xsd:element name="success" type="tns:ArrayOfSuccesses" nillable="true" />
337
+ <xsd:element name="failures" type="tns:ArrayOfFailures" nillable="true" />
338
+ </xsd:all>
339
+ </xsd:complexType>
340
+ <xsd:complexType name="responseInfo">
341
+ <xsd:all>
342
+ <xsd:element name="totalResults" type="xsd:int" nillable="true" />
343
+ <xsd:element name="startOffset" type="xsd:int" nillable="true" />
344
+ <xsd:element name="endOffset" type="xsd:int" nillable="true" />
345
+ <xsd:element name="requestTime" type="xsd:int" nillable="true" />
346
+ <xsd:element name="message" type="xsd:string" nillable="true" />
347
+ </xsd:all>
348
+ </xsd:complexType>
349
+ </xsd:schema>
350
+ </types>
351
+ <portType name="transactionPort">
352
+ <operation name="getTransactions">
353
+ <documentation>Get transactions</documentation>
354
+ <input message="tns:getTransactionsIn" />
355
+ <output message="tns:getTransactionsOut" />
356
+ </operation>
357
+ <operation name="validateTransaction">
358
+ <documentation>Validate transaction by affiliatemarketing_id or by program_tag | max 5000 per request</documentation>
359
+ <input message="tns:validateTransactionIn" />
360
+ <output message="tns:validateTransactionOut" />
361
+ </operation>
362
+ </portType>
363
+ <binding name="transactionBinding" type="tns:transactionPort">
364
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
365
+ <operation name="getTransactions">
366
+ <soap:operation soapAction="http://api.daisycon.com/advertiser/soap//transaction/#getTransactions" />
367
+ <input>
368
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://api.daisycon.com/advertiser/soap//transaction/" />
369
+ </input>
370
+ <output>
371
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://api.daisycon.com/advertiser/soap//transaction/" />
372
+ </output>
373
+ </operation>
374
+ <operation name="validateTransaction">
375
+ <soap:operation soapAction="http://api.daisycon.com/advertiser/soap//transaction/#validateTransaction" />
376
+ <input>
377
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://api.daisycon.com/advertiser/soap//transaction/" />
378
+ </input>
379
+ <output>
380
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://api.daisycon.com/advertiser/soap//transaction/" />
381
+ </output>
382
+ </operation>
383
+ </binding>
384
+ <service name="transactionService">
385
+ <port name="transactionPort" binding="tns:transactionBinding">
386
+ <soap:address location="http://api.daisycon.com/advertiser/soap//transaction/" />
387
+ </port>
388
+ </service>
389
+ <message name="getTransactionsIn">
390
+ <part name="filter" type="tns:transactionsFilter" />
391
+ </message>
392
+ <message name="getTransactionsOut">
393
+ <part name="return" type="tns:ArrayOfTransaction" />
394
+ <part name="responseInfo" type="tns:responseInfo" />
395
+ </message>
396
+ <message name="validateTransactionIn">
397
+ <part name="transactions" type="tns:ArrayOfValidate_transaction" />
398
+ </message>
399
+ <message name="validateTransactionOut">
400
+ <part name="return" type="tns:validatedTransactionReturn" />
401
+ <part name="responseInfo" type="tns:responseInfo" />
402
+ </message>
403
+ </definitions>
@@ -26,7 +26,7 @@ describe Sekken::Operation do
26
26
  client.operation(service, port, 'VatAccount_UpdateFromDataArray')
27
27
  }
28
28
 
29
- let(:zanox_export_service){
29
+ let(:zanox_export_service){
30
30
  client = Sekken.new fixture('wsdl/zanox_export_service')
31
31
 
32
32
  service, port = "ExportService", "ExportServiceSoap"
@@ -35,6 +35,34 @@ describe Sekken::Operation do
35
35
  }
36
36
 
37
37
  describe '#build' do
38
+ describe 'multiple calls' do
39
+ let(:body) do
40
+ {
41
+ addLogins: {
42
+ accounts: [
43
+ {
44
+ username: 'first',
45
+ password: 'secret',
46
+ contactInformation: {
47
+ email: 'first@example.com',
48
+ _type: 'any'
49
+ }
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ end
55
+
56
+ it 'cached on next call' do
57
+ add_logins.body = body
58
+
59
+ first_call = add_logins.build
60
+ second_call = add_logins.build
61
+
62
+ expect(first_call).to eq(second_call)
63
+ end
64
+ end
65
+
38
66
  it 'expects Arrays of complex types as Arrays of Hashes' do
39
67
  add_logins.body = {
40
68
  addLogins: {
@@ -46,7 +74,7 @@ describe Sekken::Operation do
46
74
  username: 'first',
47
75
  password: 'secret',
48
76
  contactInformation: {
49
- email: 'first@example.com',
77
+ email: 'first@example.com'
50
78
  }
51
79
  },
52
80
  {
@@ -187,7 +215,7 @@ describe Sekken::Operation do
187
215
  to raise_error(ArgumentError, "Expected an Array of values for the :betId simple type")
188
216
  end
189
217
 
190
- it 'test' do
218
+ it 'expects elements of Hashes containing attributes and key with same to return corresponding xml with attributes and text inside' do
191
219
  zanox_export_service.header = {
192
220
  zanox: {
193
221
  ticket: 'EFB745D691DBFF2DFA9F8B10A4D7A7B1AEA850CD'
@@ -198,7 +226,7 @@ describe Sekken::Operation do
198
226
  programid: 5574,
199
227
  ppsfilter: {
200
228
  period: {
201
- :_from => '2013-10-01T00:00:00+02:00',
229
+ :_from => '2013-10-01T00:00:00+02:00',
202
230
  :_to => '2013-11-12T00:00:00+02:00'
203
231
  },
204
232
  :reviewstate => {reviewstate: 0, :_negate => 1},
@@ -227,7 +255,7 @@ describe Sekken::Operation do
227
255
  </env:Envelope>})
228
256
 
229
257
  expect(Nokogiri.XML zanox_export_service.build).
230
- to be_equivalent_to(expected).respecting_element_order
258
+ to be_equivalent_to(expected).respecting_element_order
231
259
  end
232
260
 
233
261
  it 'expects Array of Hashes with attributes to return Array of complex types with attributes' do
@@ -303,6 +331,47 @@ describe Sekken::Operation do
303
331
  expect(Nokogiri.XML vatAccount_update_from_data_array.build).
304
332
  to be_equivalent_to(expected).respecting_element_order
305
333
  end
334
+
335
+ # TODO: Finish me
336
+
337
+ # let(:test_body) do
338
+ # client = Savon.new fixture('wsdl/daisycon.wsdl')
339
+
340
+ # service, port = "transactionService", "transactionPort"
341
+
342
+ # client.operation(service, port, 'validateTransaction')
343
+ # end
344
+ # it 'test' do
345
+ # test_body.body = {
346
+ # transactions: {
347
+ # "validate_transaction" => {
348
+ # "program_id" => 5623,
349
+ # "affiliatemarketing_id" => "WQACE273RVA8YF49YQ",
350
+ # "status" => "disapproved",
351
+ # "disapprove_reason" => "testorder"
352
+ # }
353
+ # }
354
+ # }
355
+
356
+ # expected = Nokogiri.XML(%{
357
+ # <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.daisycon.com/advertiser/soap//transaction/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
358
+ # <env:Body>
359
+ # <tns:validateTransaction>
360
+ # <transactions>
361
+ # <validate_transaction>
362
+ # <program_id>5623</program_id>
363
+ # <affiliatemarketing_id>WQACE273RVA8YF49YQ</affiliatemarketing_id>
364
+ # <status>disapproved</status>
365
+ # <disapprove_reason>testorder</disapprove_reason>
366
+ # </validate_transaction>
367
+ # </transactions>
368
+ # </tns:validateTransaction>
369
+ # </env:Body>
370
+ # </env:Envelope>
371
+ # })
372
+
373
+ # expect( Nokogiri.XML test_body.build ).to be_equivalent_to(expected).respecting_element_order
374
+ # end
306
375
  end
307
376
 
308
377
  end
@@ -54,8 +54,7 @@ describe Sekken::Operation do
54
54
  describe '#http_headers' do
55
55
  it 'returns a Hash of HTTP headers for a SOAP 1.2 operation' do
56
56
  expect(operation.http_headers).to eq(
57
- 'SOAPAction' => '"http://www.webserviceX.NET/ConvertTemp"',
58
- 'Content-Type' => 'application/soap+xml;charset=UTF-8'
57
+ 'Content-Type' => 'application/soap+xml;charset=UTF-8;action="http://www.webserviceX.NET/ConvertTemp"'
59
58
  )
60
59
  end
61
60
 
@@ -96,6 +96,42 @@ describe Sekken::XS::ComplexType do
96
96
  expect(complex_type.collect_child_elements).to eq(all_elements)
97
97
  end
98
98
 
99
+ specify 'complexType/simpleContent (plus annotations)' do
100
+ base_type = new_complex_type('
101
+ <complexType name="baseObject">
102
+ <sequence>
103
+ <element minOccurs="0" maxOccurs="unbounded" name="ExemptState" nillable="true" type="tns:ExemptState" />
104
+ </sequence>
105
+ </complexType>
106
+ ')
107
+ schemas = mock('schemas')
108
+ schemas.expects(:complex_type).with('http://example.com/ons', 'baseObject').returns(base_type)
109
+
110
+ complex_type = new_complex_type('
111
+ <complexType name="Account" xmlns="http://www.w3.org/2001/XMLSchema"
112
+ xmlns:ons="http://example.com/ons"
113
+ xmlns:ens="http://example.com/ens">
114
+ <xs:annotation>
115
+ <xs:documentation>
116
+ Basic type for specifying measures and the system of measurement.
117
+ </xs:documentation>
118
+ </xs:annotation>
119
+
120
+ <complexContent>
121
+ <extension base="ons:baseObject">
122
+ <sequence>
123
+ <element minOccurs="0" name="The Child Element" nillable="true" type="string" />
124
+ </sequence>
125
+ </extension>
126
+ </complexContent>
127
+ </complexType>
128
+ ', schemas)
129
+
130
+ children = complex_type.collect_child_elements
131
+ expect(children.size).to eq(2)
132
+ expect(children[1].name).to eq('The Child Element')
133
+ end
134
+
99
135
  specify 'complexType/simpleContent/attribute (plus annotations)' do
100
136
  complex_type = new_complex_type('
101
137
  <xs:complexType name="MeasureType">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sekken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-14 00:00:00.000000000 Z
12
+ date: 2014-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nori
@@ -146,6 +146,7 @@ files:
146
146
  - .gitignore
147
147
  - .travis.yml
148
148
  - .yardopts
149
+ - CHANGELOG.md
149
150
  - CONTRIBUTING.md
150
151
  - Gemfile
151
152
  - MIT-LICENSE
@@ -228,6 +229,7 @@ files:
228
229
  - spec/fixtures/wsdl/bydexchange/bydexchange7.xsd
229
230
  - spec/fixtures/wsdl/bydexchange/bydexchange8.xsd
230
231
  - spec/fixtures/wsdl/crowd.wsdl
232
+ - spec/fixtures/wsdl/daisycon.wsdl
231
233
  - spec/fixtures/wsdl/data_exchange.wsdl
232
234
  - spec/fixtures/wsdl/document_literal_wrapped.wsdl
233
235
  - spec/fixtures/wsdl/economic.wsdl