streamsend 1.0.0.rc23 → 1.0.0.rc24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDU3YTQ4ZDAxNDFmMmFlMjY5NWU1NTFmOGJlYTUwMTU5NjlhM2Q5OQ==
4
+ MDI0YmIzODVjM2UxNWY1MjIyMDlkM2NmZDZhNTcyOTdjNDkyNjMxYg==
5
5
  data.tar.gz: !binary |-
6
- ZTQ1Y2E0MGU3MWZiY2UyNmZlZTljMTYyMjVkZTI0NmNhZWVkZTg2OA==
6
+ ZThjZDhiOTViZmNhMjhlNjVmNTNjNWI4MzE2OGI4NGZmODEzNDkxZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzYxOWZiNDY3ZmNlMDE3NzEzOGQ2Mjc4MGMwN2VhM2E3Yjk3ZDZkMDc2NDM0
10
- Mzc5YzczZTIzNjNiMmZkMjA2ZjUyOTU3NDZhZWMzNjEwZDZiZjQwMTg4ODRi
11
- YTVmODA4N2M0MmRmZjU2MGEwOWI5Y2M0MTM3NGY5YmJmNWI4MTE=
9
+ ZTllYzBlNDExMWYzN2MxOThlYWFiNzY3M2I1NGEyOWYzOTgwZjNlNTQwMTcw
10
+ MWI0ZTBhYzQ3MTM3ZDk4ZGVjNThmMGFmZDQwMDNkNDEzNDgwYjJiMDllZDQ5
11
+ NGQ4M2U3NjU1NTIwMzU3NWVjYTEzZGNiMGJiNDZkNmZlOGM4ZWI=
12
12
  data.tar.gz: !binary |-
13
- YjM2ZDNjMWY2YmIzM2M4MWIxOWRlMmMxMzUzM2Y0MDRkYmY3OGNkOWNjYTg2
14
- MTQyMjVhMDA1M2E1NTg0ZmI3YTliYzRlMDM5YzRkYWZlMmVmYjcxMmQzZTky
15
- YTk1MTE4YTUxYTZiODgxZjhkNTU4OGMyNTA4ZDIxNjQ3NDE4ZmE=
13
+ YjYwNDE2NjljNDk3Y2Y1ZTIyYzUzMWNhZjFiOWJjNjExZjg4OWI1YmY3YzY0
14
+ NWFiMDI5MGJmZTdkMTc0ZmRmZjZiMGVhNzk2ZDU5Zjk5NWZiYzhlNTU3YmE3
15
+ NTZkODljMTQ3ZWYzMWFmZDgzMjljNGJlY2Q2NjUyZmY2ZDJlZGU=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- streamsend (1.0.0.rc22)
4
+ streamsend (1.0.0.rc24)
5
5
  activesupport (~> 3.2)
6
6
  builder
7
7
  httmultiparty
data/README.md CHANGED
@@ -43,10 +43,7 @@ request.
43
43
 
44
44
  **Making Calls**
45
45
 
46
- The show and index calls return a single or array of StreamSend::Api::Result
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.new(data) }
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.new(response.parsed_response[namespace.singularize])
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
@@ -1,3 +1,3 @@
1
1
  module StreamSend
2
- VERSION = "1.0.0.rc23"
2
+ VERSION = "1.0.0.rc24"
3
3
  end
@@ -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 => {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamsend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc23
4
+ version: 1.0.0.rc24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Yeo