office_autopilot_api 0.1.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.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe OfficeAutopilotApi::Client do
4
+
5
+ before do
6
+ @api_id = 'foo'
7
+ @api_key = 'bar'
8
+ @client = OfficeAutopilotApi::Client.new(:api_id => @api_id, :api_key => @api_key)
9
+ end
10
+
11
+ describe "#new" do
12
+ it "initializes with the given API credentials" do
13
+ @client.api_id.should == @api_id
14
+ @client.api_key.should == @api_key
15
+ @client.auth.should == { 'Appid' => @api_id, 'Key' => @api_key }
16
+ end
17
+
18
+ it "raises an ArgumentError when :api_id is not provided" do
19
+ expect {
20
+ OfficeAutopilotApi::Client.new(:api_key => 'foo')
21
+ }.to raise_error(ArgumentError)
22
+ end
23
+
24
+ it "raises an ArgumentError when :api_key is not provided" do
25
+ expect {
26
+ OfficeAutopilotApi::Client.new(:api_id => 'foo')
27
+ }.to raise_error(ArgumentError)
28
+ end
29
+ end
30
+
31
+ describe "#request" do
32
+ it "makes a HTTP request" do
33
+ pending "can't seem to stub out OfficeAutopilotApi::Request.post"
34
+ end
35
+ end
36
+
37
+ describe "#handle_response" do
38
+ context "when there are no errors" do
39
+ it "returns the response verbatim" do
40
+ response = '<result>Success</result>'
41
+ @client.handle_response(response).should == response
42
+ end
43
+ end
44
+
45
+ context "invalid XML error" do
46
+ it "raises OfficeAutopilotApi::XmlError" do
47
+ expect {
48
+ @client.handle_response( test_data('invalid_xml_error_response.xml') )
49
+ }.to raise_error(OfficeAutopilotApi::XmlError)
50
+ end
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe OfficeAutopilotApi::Request do
4
+
5
+ describe "HTTParty" do
6
+ it "sets the base uri to the Office Autopilot API host" do
7
+ OfficeAutopilotApi::Request.base_uri.should == 'http://api.moon-ray.com'
8
+ end
9
+
10
+ it "set the format to :plain" do
11
+ OfficeAutopilotApi::Request.format.should == :plain
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,25 @@
1
+ require 'office_autopilot_api'
2
+
3
+ require 'cgi'
4
+ require 'webmock/rspec'
5
+
6
+
7
+ # disallow all non-local connections
8
+ #WebMock.disable_net_connect!(:allow_localhost => true)
9
+
10
+
11
+ RSpec.configure do |config|
12
+ end
13
+
14
+
15
+ def test_data(file_name)
16
+ File.read(File.join(File.dirname(__FILE__), 'data', file_name))
17
+ end
18
+
19
+ def api_endpoint
20
+ "http://api.moon-ray.com"
21
+ end
22
+
23
+ def escape_xml(xml)
24
+ CGI.escape(xml).gsub('+', '%20')
25
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: office_autopilot_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Prashant Nadarajan
8
+ - parasquid
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '0.8'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '0.8'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '2.5'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '2.5'
42
+ - !ruby/object:Gem::Dependency
43
+ name: webmock
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: httparty
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '0.7'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.7'
70
+ - !ruby/object:Gem::Dependency
71
+ name: builder
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 2.1.2
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: 2.1.2
84
+ - !ruby/object:Gem::Dependency
85
+ name: nokogiri
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '1.4'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '1.4'
98
+ description: A Ruby wrapper for the OfficeAutopilot API
99
+ email:
100
+ - prashant.nadarajan@gmail.com
101
+ - parasquid
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - .gitignore
107
+ - .rspec
108
+ - Gemfile
109
+ - MIT-LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - lib/office_autopilot_api.rb
113
+ - lib/office_autopilot_api/client.rb
114
+ - lib/office_autopilot_api/client/contacts.rb
115
+ - lib/office_autopilot_api/error.rb
116
+ - lib/office_autopilot_api/request.rb
117
+ - lib/office_autopilot_api/version.rb
118
+ - office_autopilot_api.gemspec
119
+ - spec/data/contacts_add_response.xml
120
+ - spec/data/contacts_fetch_sequences.xml
121
+ - spec/data/contacts_key_type.xml
122
+ - spec/data/contacts_pull_tags.xml
123
+ - spec/data/contacts_search_multiple_response.xml
124
+ - spec/data/contacts_search_single_response.xml
125
+ - spec/data/invalid_contact_ids_error.xml
126
+ - spec/data/invalid_xml_error_response.xml
127
+ - spec/office_autopilot_api/client/contacts_spec.rb
128
+ - spec/office_autopilot_api/client_spec.rb
129
+ - spec/office_autopilot_api/request_spec.rb
130
+ - spec/spec_helper.rb
131
+ homepage: https://github.com/parasquid/office_autopilot
132
+ licenses: []
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project: office_autopilot_api
150
+ rubygems_version: 2.0.3
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Ruby wrapper for the OfficeAutopilot API
154
+ test_files:
155
+ - spec/data/contacts_add_response.xml
156
+ - spec/data/contacts_fetch_sequences.xml
157
+ - spec/data/contacts_key_type.xml
158
+ - spec/data/contacts_pull_tags.xml
159
+ - spec/data/contacts_search_multiple_response.xml
160
+ - spec/data/contacts_search_single_response.xml
161
+ - spec/data/invalid_contact_ids_error.xml
162
+ - spec/data/invalid_xml_error_response.xml
163
+ - spec/office_autopilot_api/client/contacts_spec.rb
164
+ - spec/office_autopilot_api/client_spec.rb
165
+ - spec/office_autopilot_api/request_spec.rb
166
+ - spec/spec_helper.rb