streamsend 1.0.0.rc23 → 1.0.0.rc24
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 +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +9 -4
- data/lib/streamsend/api/base/index.rb +1 -1
- data/lib/streamsend/api/base/show.rb +1 -1
- data/lib/streamsend/version.rb +1 -1
- data/spec/lib/streamsend/api/unit/base/index_spec.rb +8 -0
- data/spec/lib/streamsend/api/unit/base/show_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDI0YmIzODVjM2UxNWY1MjIyMDlkM2NmZDZhNTcyOTdjNDkyNjMxYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZThjZDhiOTViZmNhMjhlNjVmNTNjNWI4MzE2OGI4NGZmODEzNDkxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTllYzBlNDExMWYzN2MxOThlYWFiNzY3M2I1NGEyOWYzOTgwZjNlNTQwMTcw
|
10
|
+
MWI0ZTBhYzQ3MTM3ZDk4ZGVjNThmMGFmZDQwMDNkNDEzNDgwYjJiMDllZDQ5
|
11
|
+
NGQ4M2U3NjU1NTIwMzU3NWVjYTEzZGNiMGJiNDZkNmZlOGM4ZWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjYwNDE2NjljNDk3Y2Y1ZTIyYzUzMWNhZjFiOWJjNjExZjg4OWI1YmY3YzY0
|
14
|
+
NWFiMDI5MGJmZTdkMTc0ZmRmZjZiMGVhNzk2ZDU5Zjk5NWZiYzhlNTU3YmE3
|
15
|
+
NTZkODljMTQ3ZWYzMWFmZDgzMjljNGJlY2Q2NjUyZmY2ZDJlZGU=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,10 +43,7 @@ request.
|
|
43
43
|
|
44
44
|
**Making Calls**
|
45
45
|
|
46
|
-
|
47
|
-
objects. The StreamSend::Api::Result object is just an OpenStruct that responds
|
48
|
-
to id with the hash value of id rather than the Ruby id. It also has to_hash
|
49
|
-
defined as an alias to marshaldump. Create and update take an object hash of
|
46
|
+
Create and update take an object hash of
|
50
47
|
whatever it is that you're creating/updating. The object values should be nested
|
51
48
|
in a hash with a key corresponding to the object type:
|
52
49
|
|
@@ -57,6 +54,14 @@ OR
|
|
57
54
|
{ :list => my_list_result_object.to_hash }
|
58
55
|
#working with a result object named my_list_result_object.
|
59
56
|
|
57
|
+
**Result Object**
|
58
|
+
|
59
|
+
The Result object is an OpenStruct that has nested OpenStructs instead of hashes for child objects. This enables
|
60
|
+
the result object to use dot notation for all attributes:
|
61
|
+
|
62
|
+
blasts = StreamSend::Api::Blast::Index.new(session).execute
|
63
|
+
blasts.first.from.name (NOT blasts.first.from[:name])
|
64
|
+
|
60
65
|
### Examples:
|
61
66
|
|
62
67
|
**Index**
|
@@ -9,7 +9,7 @@ module StreamSend
|
|
9
9
|
response = session.get(uri, options)
|
10
10
|
case response.code
|
11
11
|
when 200
|
12
|
-
response.parsed_response[namespace].collect { |data| StreamSend::Api::Result.
|
12
|
+
response.parsed_response[namespace].collect { |data| StreamSend::Api::Result.create_nested_result_object(data) }
|
13
13
|
when 400
|
14
14
|
raise StreamSend::Api::ApiException.new(get_error_from(response))
|
15
15
|
when 401
|
@@ -7,7 +7,7 @@ module StreamSend
|
|
7
7
|
response = session.get(uri, show_options)
|
8
8
|
case response.code
|
9
9
|
when 200
|
10
|
-
StreamSend::Api::Result.
|
10
|
+
StreamSend::Api::Result.create_nested_result_object(response.parsed_response[namespace.singularize])
|
11
11
|
else
|
12
12
|
raise StreamSend::Api::Exception.new("Could not find any #{namespace} with the specified id. (#{response.code})")
|
13
13
|
end
|
data/lib/streamsend/version.rb
CHANGED
@@ -8,6 +8,7 @@ module StreamSend
|
|
8
8
|
let(:indexer){ Index.new(session) }
|
9
9
|
let(:options){ {:page => 2, :per_page => 10} }
|
10
10
|
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
|
11
|
+
let(:complex_xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><tests><one>1</one></tests></call></calls>" }
|
11
12
|
|
12
13
|
describe "#uris" do
|
13
14
|
before do
|
@@ -28,6 +29,13 @@ module StreamSend
|
|
28
29
|
expect(indexer.execute[0].test).to eq(1)
|
29
30
|
end
|
30
31
|
|
32
|
+
it "creates an array of nested Result objects" do
|
33
|
+
stub_request(:get, "http://test:password@default.base/calls.xml").
|
34
|
+
to_return(:status => 200, :body => complex_xml, :headers => {'Content-type' => 'application/xml'})
|
35
|
+
results = indexer.execute
|
36
|
+
expect(results[0].tests.one).to eq("1")
|
37
|
+
end
|
38
|
+
|
31
39
|
it "builds an error message with the namespace name if the status is not a 200" do
|
32
40
|
stub_request(:get, "http://test:password@default.base/calls.xml").to_return(:status => 404, :body => xml, :headers => {})
|
33
41
|
expect do
|
@@ -8,6 +8,7 @@ module StreamSend
|
|
8
8
|
let(:shower){ Show.new(session) }
|
9
9
|
let(:id){ 1 }
|
10
10
|
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><call><test type=\"integer\">1</test></call>" }
|
11
|
+
let(:complex_xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><call><tests><one>1</one></tests></call>" }
|
11
12
|
|
12
13
|
it "returns a Result object if the object is found" do
|
13
14
|
stub_request(:get, "http://test:password@default.base/calls/1.xml").
|
@@ -15,6 +16,12 @@ module StreamSend
|
|
15
16
|
expect(shower.execute(id).test).to eq(1)
|
16
17
|
end
|
17
18
|
|
19
|
+
it "returns a nested Result object if the result is nested" do
|
20
|
+
stub_request(:get, "http://test:password@default.base/calls/1.xml").
|
21
|
+
to_return(:status => 200, :body => complex_xml, :headers => {'Content-Type' => 'text/xml'})
|
22
|
+
expect(shower.execute(id).tests.one).to eq("1")
|
23
|
+
end
|
24
|
+
|
18
25
|
it "throws an exception if the object is not found" do
|
19
26
|
stub_request(:get, "http://test:password@default.base/calls/1.xml").
|
20
27
|
to_return(:status => 404, :body => xml, :headers => {})
|