oneview 0.0.2 → 0.0.4
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 +4 -4
- data/README.md +2 -1
- data/lib/oneview/api/emails.rb +21 -0
- data/lib/oneview/client.rb +5 -1
- data/lib/oneview/entity/email.rb +7 -0
- data/lib/oneview/version.rb +1 -1
- data/spec/oneview/api/emails_spec.rb +41 -0
- data/spec/oneview/entity/email_spec.rb +19 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cf6bfab53f6829c6309a02e640d0232e06b73bd
|
4
|
+
data.tar.gz: 3016192c9ea499f1f16eb09d44805520d7204772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba39829a16584fd30f85067667a9365264fba729e7e0aa74ecf50d0b6ea6ff341af616d61b76364801357934200f8d975150fe75b5c950e5189e25d97b247ea
|
7
|
+
data.tar.gz: 66f2867966193571c881a66927f5f557aad4244a6f562e3d69b5ee46d1d2465795e613819936d907374ea1d0cf88afada055f34ed966f4cccac466a08f18d4db
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ With the client instance, you can access the following resources:
|
|
32
32
|
|
33
33
|
* Contacts (client.contacts) **Only creation**
|
34
34
|
* Sms Sending (client.sms) **Not Implemented Yet**
|
35
|
-
* Email Sending (client.email)
|
35
|
+
* Email Sending (client.email)
|
36
36
|
|
37
37
|
## Using the resources
|
38
38
|
### Creating new records
|
@@ -45,6 +45,7 @@ Currently the following entities are implemented:
|
|
45
45
|
* [Contact](lib/oneview/entity/contact.rb)
|
46
46
|
* [Phone](lib/oneview/entity/phone.rb)
|
47
47
|
* [Dynamic Field](lib/oneview/entity/dynamic_field.rb)
|
48
|
+
* [Email](lib/oneview/entity/email.rb)
|
48
49
|
|
49
50
|
### Reading the response
|
50
51
|
All methods return an Oneview::Client::Response object. This objects contains the following attributes:
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Oneview
|
2
|
+
module Api
|
3
|
+
class Emails < Client
|
4
|
+
require_all 'oneview/entity', 'email'
|
5
|
+
|
6
|
+
base_uri "http://www.oneview.com.br/api/senders/send_email"
|
7
|
+
|
8
|
+
def create(data)
|
9
|
+
return parse_response(self.class.post("/", :body => build_body(data), :headers => header)) if data.is_a?(Hash)
|
10
|
+
return parse_response(self.class.post("/", :body => build_body(data.as_parameter), :headers => header)) if data.is_a?(Oneview::Entity::Email)
|
11
|
+
raise ArgumentError
|
12
|
+
end
|
13
|
+
alias :new :create
|
14
|
+
|
15
|
+
private
|
16
|
+
def build_body(parameters)
|
17
|
+
super(parameters)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/oneview/client.rb
CHANGED
@@ -11,7 +11,7 @@ module Oneview
|
|
11
11
|
extend Oneview::ClassMethods
|
12
12
|
include HTTParty
|
13
13
|
|
14
|
-
require_all 'oneview/api', 'contacts'
|
14
|
+
require_all 'oneview/api', 'contacts', 'emails'
|
15
15
|
|
16
16
|
attr_accessor :access_token
|
17
17
|
|
@@ -24,6 +24,10 @@ module Oneview
|
|
24
24
|
Oneview::Api::Contacts.new(@access_token)
|
25
25
|
end
|
26
26
|
|
27
|
+
def emails
|
28
|
+
Oneview::Api::Emails.new(@access_token)
|
29
|
+
end
|
30
|
+
|
27
31
|
protected
|
28
32
|
def header
|
29
33
|
{"Content-Type" => "application/json", "Accept" => "application/json"}
|
data/lib/oneview/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Api::Emails do
|
4
|
+
describe "creating" do
|
5
|
+
let(:email_params) {{:from => "from@email.com", :to => "to@email.com", :body => "body", :subject => "subject", :schedule => "14/05/2014 15:30", :access_token => "abc"}}
|
6
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@email = Oneview::Entity::Email.new
|
10
|
+
@email.from = "from@email.com"
|
11
|
+
@email.to = "to@email.com"
|
12
|
+
@email.body = "body"
|
13
|
+
@email.subject = "subject"
|
14
|
+
@email.schedule = "14/05/2014 15:30"
|
15
|
+
|
16
|
+
stub_request(:post, "http://www.oneview.com.br/api/senders/send_email/").to_return(:status => 200)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with raw parameters" do
|
20
|
+
it "should post to the send email url" do
|
21
|
+
expect(Oneview::Api::Emails).to receive(:post).with("/", :body => email_params.to_json, :headers => header).and_call_original
|
22
|
+
|
23
|
+
Oneview.new("abc").emails.create(email_params)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "with entity parameter" do
|
28
|
+
it "should post to the send email url" do
|
29
|
+
expect(Oneview::Api::Emails).to receive(:post).with("/", :body => @email.as_parameter.merge(:access_token => "abc").to_json, :headers => header).and_call_original
|
30
|
+
|
31
|
+
Oneview.new("abc").emails.create(@email)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "with invalid parameter" do
|
36
|
+
it "should raise ArgumentError when passing neither a Hash nor an Email" do
|
37
|
+
expect{Oneview.new("abc").emails.create(Array.new)}.to raise_error(ArgumentError)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Entity::Email do
|
4
|
+
describe "as_parameter" do
|
5
|
+
let(:email_as_parameter) {{"from" => "test@test.com", "to" => "test2@test2.com", "body" => "Bodys Test",
|
6
|
+
"subject" => "Subjects Test"}}
|
7
|
+
|
8
|
+
it "should return the email as parameter" do
|
9
|
+
email = Oneview::Entity::Email.new
|
10
|
+
|
11
|
+
email.from = "test@test.com"
|
12
|
+
email.to = "test2@test2.com"
|
13
|
+
email.body = "Bodys Test"
|
14
|
+
email.subject = "Subjects Test"
|
15
|
+
|
16
|
+
expect(email.as_parameter).to eq(email_as_parameter)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Berdugo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -54,17 +54,21 @@ files:
|
|
54
54
|
- Rakefile
|
55
55
|
- lib/oneview.rb
|
56
56
|
- lib/oneview/api/contacts.rb
|
57
|
+
- lib/oneview/api/emails.rb
|
57
58
|
- lib/oneview/client.rb
|
58
59
|
- lib/oneview/entity/base.rb
|
59
60
|
- lib/oneview/entity/contact.rb
|
60
61
|
- lib/oneview/entity/dynamic_field.rb
|
62
|
+
- lib/oneview/entity/email.rb
|
61
63
|
- lib/oneview/entity/phone.rb
|
62
64
|
- lib/oneview/version.rb
|
63
65
|
- oneview.gemspec
|
64
66
|
- spec/oneview/api/contacts_spec.rb
|
67
|
+
- spec/oneview/api/emails_spec.rb
|
65
68
|
- spec/oneview/client_spec.rb
|
66
69
|
- spec/oneview/entity/contact_spec.rb
|
67
70
|
- spec/oneview/entity/dynamic_field_spec.rb
|
71
|
+
- spec/oneview/entity/email_spec.rb
|
68
72
|
- spec/oneview/entity/phone_spec.rb
|
69
73
|
- spec/oneview_spec.rb
|
70
74
|
- spec/spec_helper.rb
|
@@ -88,15 +92,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
92
|
version: '0'
|
89
93
|
requirements: []
|
90
94
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.4.
|
95
|
+
rubygems_version: 2.4.5
|
92
96
|
signing_key:
|
93
97
|
specification_version: 4
|
94
98
|
summary: This gem provides integration with Oneview APIs (http://www.oneview.com.br/)
|
95
99
|
test_files:
|
96
100
|
- spec/oneview/api/contacts_spec.rb
|
101
|
+
- spec/oneview/api/emails_spec.rb
|
97
102
|
- spec/oneview/client_spec.rb
|
98
103
|
- spec/oneview/entity/contact_spec.rb
|
99
104
|
- spec/oneview/entity/dynamic_field_spec.rb
|
105
|
+
- spec/oneview/entity/email_spec.rb
|
100
106
|
- spec/oneview/entity/phone_spec.rb
|
101
107
|
- spec/oneview_spec.rb
|
102
108
|
- spec/spec_helper.rb
|