oneview 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 337b3c6c73272b1e4a069237f95499346f7b3619
4
- data.tar.gz: 9e06ccc674980568d53415a18ac8e1e8577640ad
2
+ SHA256:
3
+ metadata.gz: 1857bba3aac752fce075e2650e6539f78aed654dce1606ead5e321d1a1d45cbd
4
+ data.tar.gz: a32f66a7ed8c420062e0d0aab328b87c550f2e0942793273fd478bcedda38840
5
5
  SHA512:
6
- metadata.gz: c6ed23b47f36b2be135378138eb90c17748d4e014d0b3bb893f25a16f8de3fc471274f39b7ebf22a4756898e82fb38f00dad8c5621c7db6f0d38a0d383cc020a
7
- data.tar.gz: 03fa1ea3b56b509cf05586c7dde79a26f79e9b3a2cff753179ca6642c955c99a072ee97548afbb7cc888bd48fe13e8543f872b353baa064f734254d0d3b74cd8
6
+ metadata.gz: 5956a4b6c292587295ce697a03a5ed9d1e6aba51895222d451b8c4bac5771d1e387bf0807de9518b340ed8421eac7c47fe09828b3bb930e08bf5dd16c3f03b02
7
+ data.tar.gz: 3a5a5e4999b732f61150325e9a938d0950b463bc5f0bad030627a04210162ca772dec30170e9185d6bb8938d71bd4bf90d0d7e3d16456d5e847d6fb09c265366
data/Gemfile CHANGED
@@ -3,4 +3,11 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in oneview.gemspec
4
4
  gemspec
5
5
 
6
- gem 'debugger', :group => :development
6
+ gem 'debugger', :group => :development
7
+
8
+ group :test do
9
+ gem "rspec", "~> 3.1"
10
+ gem "rake", "~> 10.3"
11
+ gem "webmock", "~> 1.20"
12
+ gem "codeclimate-test-reporter", "~> 0.4"
13
+ end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Oneview
2
2
 
3
- [![Build Status](https://travis-ci.org/coyosoftware/oneview.svg?branch=master)](https://travis-ci.org/coyosoftware/oneview) [![Gem Version](https://badge.fury.io/rb/oneview.png)](http://badge.fury.io/rb/oneview) [![Test Coverage](https://codeclimate.com/github/coyosoftware/oneview/badges/coverage.svg)](https://codeclimate.com/github/coyosoftware/oneview) [![Code Climate](https://codeclimate.com/github/coyosoftware/oneview/badges/gpa.svg)](https://codeclimate.com/github/coyosoftware/oneview)
3
+ [![Build Status](https://travis-ci.org/coyosoftware/oneview.svg?branch=master)](https://travis-ci.org/coyosoftware/oneview) [![Gem Version](https://badge.fury.io/rb/oneview.svg)](http://badge.fury.io/rb/oneview) [![Test Coverage](https://codeclimate.com/github/coyosoftware/oneview/badges/coverage.svg)](https://codeclimate.com/github/coyosoftware/oneview) [![Code Climate](https://codeclimate.com/github/coyosoftware/oneview/badges/gpa.svg)](https://codeclimate.com/github/coyosoftware/oneview)
4
4
 
5
5
  This gem simplifies the usage of [Oneview](http://www.oneview.com.br/) API
6
6
 
@@ -30,9 +30,9 @@ Create a new instance of Oneview class passing your access token:
30
30
 
31
31
  With the client instance, you can access the following resources:
32
32
 
33
- * Contacts (client.contacts) **Only creation**
34
- * Sms Sending (client.sms) **Not Implemented Yet**
35
- * Email Sending (client.email) **Not Implemented Yet**
33
+ * Contacts (client.contacts) **Create and Update**
34
+ * Sms Sending (client.sms)
35
+ * Email Sending (client.email)
36
36
 
37
37
  ## Using the resources
38
38
  ### Creating new records
@@ -45,6 +45,15 @@ 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)
49
+ * [SMS](lib/oneview/entity/sms.rb)
50
+
51
+ ### Updating records
52
+ It can accept a hash with the parameters as described in the API [documentation] or an Entity object that reflects the API fields.
53
+
54
+ Currently the following entities are implemented:
55
+
56
+ * [Contact](lib/oneview/entity/contact.rb)
48
57
 
49
58
  ### Reading the response
50
59
  All methods return an Oneview::Client::Response object. This objects contains the following attributes:
@@ -3,19 +3,28 @@ module Oneview
3
3
  class Contacts < Client
4
4
  require_all 'oneview/entity', 'contact', 'dynamic_field', 'phone'
5
5
 
6
- base_uri "http://www.oneview.com.br/api/contacts"
7
-
6
+ base_uri "https://oneview.com.br/api/contacts"
7
+
8
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::Contact)
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::Contact)
11
+
11
12
  raise ArgumentError
12
13
  end
13
14
  alias :new :create
14
-
15
+
16
+ def update(id, data)
17
+ return parse_response(self.class.patch("/" + id, body: build_body(data), headers: header)) if data.is_a?(Hash)
18
+ return parse_response(self.class.patch("/" + id, body: build_body(data.as_parameter), headers: header)) if data.is_a?(Oneview::Entity::Contact)
19
+
20
+ raise ArgumentError
21
+ end
22
+
15
23
  private
16
- def build_body(parameters)
17
- super({:contact => parameters})
18
- end
24
+
25
+ def build_body(parameters)
26
+ super(contact: parameters)
27
+ end
19
28
  end
20
29
  end
21
- end
30
+ end
@@ -0,0 +1,23 @@
1
+ module Oneview
2
+ module Api
3
+ class Emails < Client
4
+ require_all 'oneview/entity', 'email'
5
+
6
+ base_uri "https://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
+
12
+ raise ArgumentError
13
+ end
14
+ alias :new :create
15
+
16
+ private
17
+
18
+ def build_body(parameters)
19
+ super(parameters)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Oneview
2
+ module Api
3
+ class Sms < Client
4
+ require_all 'oneview/entity', 'sms'
5
+
6
+ base_uri "https://oneview.com.br/api/senders/send_sms"
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::Sms)
11
+
12
+ raise ArgumentError
13
+ end
14
+ alias :new :create
15
+
16
+ private
17
+
18
+ def build_body(parameters)
19
+ super(parameters)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -11,12 +11,13 @@ 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', 'sms'
15
15
 
16
16
  attr_accessor :access_token
17
17
 
18
18
  def initialize(access_token)
19
19
  raise NoAccessTokenError if access_token.nil? || access_token.strip == ""
20
+
20
21
  @access_token = access_token
21
22
  end
22
23
 
@@ -24,18 +25,27 @@ module Oneview
24
25
  Oneview::Api::Contacts.new(@access_token)
25
26
  end
26
27
 
28
+ def emails
29
+ Oneview::Api::Emails.new(@access_token)
30
+ end
31
+
32
+ def sms
33
+ Oneview::Api::Sms.new(@access_token)
34
+ end
35
+
27
36
  protected
28
- def header
29
- {"Content-Type" => "application/json", "Accept" => "application/json"}
30
- end
31
-
32
- def build_body(parameters)
33
- parameters.merge(:access_token => @access_token).to_json
34
- end
35
-
36
- def parse_response(response)
37
- return Oneview::Client::Response.new(response)
38
- end
37
+
38
+ def header
39
+ {"Content-Type" => "application/json", "Accept" => "application/json"}
40
+ end
41
+
42
+ def build_body(parameters)
43
+ parameters.merge(:access_token => @access_token).to_json
44
+ end
45
+
46
+ def parse_response(response)
47
+ return Oneview::Client::Response.new(response)
48
+ end
39
49
 
40
50
  class Response
41
51
  attr_accessor :status, :payload, :raw_response
@@ -0,0 +1,15 @@
1
+ module Oneview
2
+ module Entity
3
+ class Base
4
+ def as_parameter
5
+ variables = instance_variables.map do |name|
6
+ variable_name = name.to_s.tr("@", "")
7
+
8
+ [variable_name, instance_variable_get(name)]
9
+ end
10
+
11
+ Hash[variables]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -11,11 +11,11 @@ module Oneview
11
11
  def as_parameter
12
12
  variables = instance_variables.map do |name|
13
13
  case name
14
- when :@phone
15
- ["phone_attributes", instance_variable_get(name).as_parameter]
16
- when :@dynamic_fields
17
- else
18
- [name.to_s.tr("@", ""), instance_variable_get(name)]
14
+ when :@phone
15
+ ["phone_attributes", instance_variable_get(name).as_parameter]
16
+ when :@dynamic_fields
17
+ else
18
+ [name.to_s.tr("@", ""), instance_variable_get(name)]
19
19
  end
20
20
  end
21
21
 
@@ -1,17 +1,9 @@
1
+ require 'oneview/entity/base'
2
+
1
3
  module Oneview
2
4
  module Entity
3
- class DynamicField
5
+ class DynamicField < Base
4
6
  attr_accessor :name, :value
5
-
6
- def as_parameter
7
- variables = instance_variables.map do |name|
8
- variable_name = name.to_s.tr("@", "")
9
-
10
- [variable_name, instance_variable_get(name)]
11
- end
12
-
13
- Hash[variables]
14
- end
15
7
  end
16
8
  end
17
9
  end
@@ -0,0 +1,7 @@
1
+ module Oneview
2
+ module Entity
3
+ class Email < Base
4
+ attr_accessor :from, :to, :body, :subject, :schedule
5
+ end
6
+ end
7
+ end
@@ -1,17 +1,9 @@
1
+ require 'oneview/entity/base'
2
+
1
3
  module Oneview
2
4
  module Entity
3
- class Phone
5
+ class Phone < Base
4
6
  attr_accessor :id, :number, :area_code, :country_code
5
-
6
- def as_parameter
7
- variables = instance_variables.map do |name|
8
- variable_name = name.to_s.tr("@", "")
9
-
10
- [variable_name, instance_variable_get(name)]
11
- end
12
-
13
- Hash[variables]
14
- end
15
7
  end
16
8
  end
17
9
  end
@@ -0,0 +1,7 @@
1
+ module Oneview
2
+ module Entity
3
+ class Sms < Base
4
+ attr_accessor :numbers, :message, :schedule
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Oneview
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/oneview.gemspec CHANGED
@@ -21,8 +21,4 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency('httparty', "~> 0.13")
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
- spec.add_development_dependency "rake", "~> 10.3"
25
- spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
26
- spec.add_development_dependency "rspec", "~> 3.1"
27
- spec.add_development_dependency "webmock", "~> 1.20"
28
24
  end
@@ -1,11 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Oneview::Api::Contacts do
4
+ let(:header) { { "Content-Type" => "application/json", "Accept" => "application/json" } }
5
+
4
6
  describe "creating" do
5
- let(:contact_params) {{:contact => {:name => "name", :email => "email"}, :access_token => "abc"}}
6
- let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
7
+ let(:contact_params) { { contact: { name: "name", email: "email" }, access_token: "abc" } }
7
8
 
8
- before(:each) do
9
+ before do
9
10
  dynamic_field = Oneview::Entity::DynamicField.new
10
11
  dynamic_field.name = "dynamic_field"
11
12
  dynamic_field.value = "123"
@@ -25,28 +26,73 @@ RSpec.describe Oneview::Api::Contacts do
25
26
  @contact.phone = phone
26
27
  @contact.dynamic_fields << dynamic_field
27
28
 
28
- stub_request(:post, "http://www.oneview.com.br/api/contacts/").to_return(:status => 200)
29
+ stub_request(:post, "https://oneview.com.br/api/contacts/").to_return(status: 200)
29
30
  end
30
31
 
31
32
  describe "with raw parameters" do
32
- it "should post to the contacts url" do
33
- expect(Oneview::Api::Contacts).to receive(:post).with("/", :body => contact_params.to_json, :headers => header).and_call_original
33
+ it "issues a post to the contacts url" do
34
+ expect(Oneview::Api::Contacts).to receive(:post).with("/", body: contact_params.to_json, headers: header).and_call_original
34
35
 
35
- Oneview.new("abc").contacts.create({:name => "name", :email => "email"})
36
+ Oneview.new("abc").contacts.create({ name: "name", email: "email"})
36
37
  end
37
38
  end
38
39
 
39
40
  describe "with entity parameter" do
40
- it "should post to the contacts url" do
41
- expect(Oneview::Api::Contacts).to receive(:post).with("/", :body => {:contact => @contact.as_parameter, :access_token => "abc"}.to_json, :headers => header).and_call_original
41
+ it "issues a post to the contacts url" do
42
+ expect(Oneview::Api::Contacts).to receive(:post).with("/", body: { contact: @contact.as_parameter, access_token: "abc" }.to_json, headers: header).and_call_original
42
43
 
43
44
  Oneview.new("abc").contacts.create(@contact)
44
45
  end
45
46
  end
46
47
 
47
48
  describe "with invalid parameter" do
48
- it "should raise ArgumentError when passing neither a Hash nor a Contact" do
49
- expect{Oneview.new("abc").contacts.create(Array.new)}.to raise_error(ArgumentError)
49
+ it "raises ArgumentError when passing neither a Hash nor a Contact" do
50
+ expect { Oneview.new("abc").contacts.create(Array.new) }.to raise_error(ArgumentError)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "updating" do
56
+ let(:contact_params) { { contact: { name: "name", email: "email", id: "23" }, access_token: "abc" } }
57
+
58
+ before(:each) do
59
+ phone = Oneview::Entity::Phone.new
60
+ phone.country_code = "+55"
61
+ phone.area_code = "12"
62
+ phone.number = "998998789"
63
+
64
+ @contact = Oneview::Entity::Contact.new
65
+ @contact.id = "23"
66
+ @contact.name = "name"
67
+ @contact.email = "email@email.com"
68
+ @contact.birthday = "14/10/2014"
69
+ @contact.city = "city"
70
+ @contact.state = "state"
71
+ @contact.zip_code = "12233-444"
72
+ @contact.phone = phone
73
+
74
+ stub_request(:patch, "https://oneview.com.br/api/contacts/23").to_return(status: 200)
75
+ end
76
+
77
+ describe "with raw parameters" do
78
+ it "issues a patch to the contacts url" do
79
+ expect(Oneview::Api::Contacts).to receive(:patch).with("/" + contact_params[:contact][:id], body: contact_params.to_json, headers: header).and_call_original
80
+
81
+ Oneview.new("abc").contacts.update("23", { name: "name", email: "email", id: "23" })
82
+ end
83
+ end
84
+
85
+ describe "with entity parameter" do
86
+ it "issues a patch to the contacts url" do
87
+ expect(Oneview::Api::Contacts).to receive(:patch).with("/" + @contact.id, body: { contact: @contact.as_parameter, access_token: "abc" }.to_json, headers: header).and_call_original
88
+
89
+ Oneview.new("abc").contacts.update(@contact.id, @contact)
90
+ end
91
+ end
92
+
93
+ describe "with invalid parameter" do
94
+ it "raises ArgumentError when passing neither a Hash nor a Contact" do
95
+ expect { Oneview.new("abc").contacts.create(Array.new) }.to raise_error(ArgumentError)
50
96
  end
51
97
  end
52
98
  end
@@ -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, "https://oneview.com.br/api/senders/send_email/").to_return(status: 200)
17
+ end
18
+
19
+ describe "with raw parameters" do
20
+ it "issues a 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 "issues a 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 "raises 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,39 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Oneview::Api::Sms do
4
+ describe "creating" do
5
+ let(:sms_params) { { numbers: "55129985587", message: "message", 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
+ @sms = Oneview::Entity::Sms.new
10
+ @sms.numbers = "55129985587"
11
+ @sms.message = "message"
12
+ @sms.schedule = "14/05/2014 15:30"
13
+
14
+ stub_request(:post, "https://oneview.com.br/api/senders/send_sms/").to_return(status: 200)
15
+ end
16
+
17
+ describe "with raw parameters" do
18
+ it "issues a post to the send sms url" do
19
+ expect(Oneview::Api::Sms).to receive(:post).with("/", body: sms_params.to_json, headers: header).and_call_original
20
+
21
+ Oneview.new("abc").sms.create(sms_params)
22
+ end
23
+ end
24
+
25
+ describe "with entity parameter" do
26
+ it "issues a post to the send sms url" do
27
+ expect(Oneview::Api::Sms).to receive(:post).with("/", body: @sms.as_parameter.merge(access_token: "abc").to_json, headers: header).and_call_original
28
+
29
+ Oneview.new("abc").sms.create(@sms)
30
+ end
31
+ end
32
+
33
+ describe "with invalid parameter" do
34
+ it "raises ArgumentError when passing neither a Hash nor an Sms" do
35
+ expect { Oneview.new("abc").sms.create(Array.new) }.to raise_error(ArgumentError)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -5,22 +5,22 @@ RSpec.describe Oneview::Client do
5
5
  Oneview::Client.send(:public, *Oneview::Client.protected_instance_methods)
6
6
  end
7
7
 
8
- it "should raise NoAccessTokenError when creating a new client without the access token" do
9
- expect{Oneview::Client.new("")}.to raise_error(Oneview::Client::NoAccessTokenError, "Please provide an access token")
8
+ it "raises NoAccessTokenError when creating a new client without the access token" do
9
+ expect { Oneview::Client.new("") }.to raise_error(Oneview::Client::NoAccessTokenError, "Please provide an access token")
10
10
  end
11
11
 
12
- it "should return the correct headers" do
12
+ it "returns the correct headers" do
13
13
  expect(Oneview::Client.new("abc").header).to eq({"Content-Type" => "application/json", "Accept" => "application/json"})
14
14
  end
15
15
 
16
- it "should append the access token to the parameters" do
17
- expect(Oneview::Client.new("abc").build_body({:abc => "abc", :def => "def"})).to eq({:abc => "abc", :def => "def", :access_token => "abc"}.to_json)
16
+ it "appends the access token to the parameters" do
17
+ expect(Oneview::Client.new("abc").build_body(abc: "abc", def: "def")).to eq({ abc: "abc", def: "def", access_token: "abc" }.to_json)
18
18
  end
19
19
 
20
- it "should return an Oneview::Client::Response with the status" do
21
- stub_request(:post, "http://www.oneview.com.br/api/contacts/").to_return(:status => 200)
20
+ it "returns an Oneview::Client::Response with the status" do
21
+ stub_request(:post, "https://oneview.com.br/api/contacts/").to_return(status: 200)
22
22
 
23
- response = Oneview.new("abc").contacts.create({:name => "name"})
23
+ response = Oneview.new("abc").contacts.create(name: "name")
24
24
 
25
25
  expect(response.class).to eq(Oneview::Client::Response)
26
26
  expect(response.status).to eq(200)
@@ -2,11 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Oneview::Entity::Contact do
4
4
  describe "as_parameter" do
5
- let(:contact_as_parameter) {{"name" => "name", "email" => "email@email.com", "birthday" => "14/10/2014", "city" => "city", "state" => "state",
6
- "zip_code" => "12233-444", "phone_attributes" => {"country_code" => "+55", "area_code" => "12", "number" => "998998789"},
7
- "dynamic_field" => "123"}}
5
+ let(:contact_as_parameter) do
6
+ {
7
+ "name" => "name", "email" => "email@email.com", "birthday" => "14/10/2014", "city" => "city", "state" => "state",
8
+ "zip_code" => "12233-444", "phone_attributes" => { "country_code" => "+55", "area_code" => "12", "number" => "998998789" },
9
+ "dynamic_field" => "123"
10
+ }
11
+ end
8
12
 
9
- it "should return the contact as parameter" do
13
+ it "returns the contact as parameter" do
10
14
  contact = Oneview::Entity::Contact.new
11
15
 
12
16
  contact.name = "name"
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Oneview::Entity::DynamicField do
4
4
  describe "as_parameter" do
5
- let(:dynamic_field_as_parameter) {{"name" => "dynamic_field", "value" => "abc"}}
5
+ let(:dynamic_field_as_parameter) { { "name" => "dynamic_field", "value" => "abc" } }
6
6
 
7
- it "should return the dynamic_field as parameter" do
7
+ it "returns the dynamic_field as parameter" do
8
8
  dynamic_field = Oneview::Entity::DynamicField.new
9
9
  dynamic_field.name = "dynamic_field"
10
10
  dynamic_field.value = "abc"
@@ -0,0 +1,18 @@
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", "subject" => "Subjects Test" } }
6
+
7
+ it "returns the email as parameter" do
8
+ email = Oneview::Entity::Email.new
9
+
10
+ email.from = "test@test.com"
11
+ email.to = "test2@test2.com"
12
+ email.body = "Bodys Test"
13
+ email.subject = "Subjects Test"
14
+
15
+ expect(email.as_parameter).to eq(email_as_parameter)
16
+ end
17
+ end
18
+ end
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Oneview::Entity::Phone do
4
4
  describe "as_parameter" do
5
- let(:phone_as_parameter) {{"number" => "999999999", "area_code" => "12", "country_code" => "+55"}}
5
+ let(:phone_as_parameter) { { "number" => "999999999", "area_code" => "12", "country_code" => "+55" } }
6
6
 
7
- it "should return the phone as parameter" do
7
+ it "returns the phone as parameter" do
8
8
  phone = Oneview::Entity::Phone.new
9
9
  phone.country_code = "+55"
10
10
  phone.area_code = "12"
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Oneview::Entity::Sms do
4
+ describe "as_parameter" do
5
+ let(:sms_as_parameter) { { "numbers" => "5512998998798", "message" => "Bodys Test" } }
6
+
7
+ it "returns the sms as parameter" do
8
+ sms = Oneview::Entity::Sms.new
9
+
10
+ sms.message = "Bodys Test"
11
+ sms.numbers = "5512998998798"
12
+
13
+ expect(sms.as_parameter).to eq(sms_as_parameter)
14
+ end
15
+ end
16
+ end
data/spec/oneview_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Oneview do
4
- it "should return a new Oneview::Client" do
4
+ it "returns a new Oneview::Client" do
5
5
  expect(Oneview.new("abc").class).to eq(Oneview::Client)
6
6
  end
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  require "codeclimate-test-reporter"
2
2
  CodeClimate::TestReporter.start
3
3
 
4
- require 'debugger'
5
4
  require 'oneview'
6
5
  require 'webmock/rspec'
7
6
 
7
+ WebMock.disable_net_connect!(allow: "codeclimate.com")
8
+
8
9
  RSpec.configure do |config|
9
10
  config.mock_with :rspec
10
11
  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.1
4
+ version: 0.1.0
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-11 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,62 +38,6 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '10.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '10.3'
55
- - !ruby/object:Gem::Dependency
56
- name: codeclimate-test-reporter
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '0.4'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '0.4'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: '3.1'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: '3.1'
83
- - !ruby/object:Gem::Dependency
84
- name: webmock
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '1.20'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ~>
95
- - !ruby/object:Gem::Version
96
- version: '1.20'
97
41
  description: 'The goal of this gem is to simplify the access to Oneview API (http://www.oneview.com.br/),
98
42
  for more information about this API, visit: http://coyosoftware.github.io/'
99
43
  email:
@@ -110,17 +54,26 @@ files:
110
54
  - Rakefile
111
55
  - lib/oneview.rb
112
56
  - lib/oneview/api/contacts.rb
57
+ - lib/oneview/api/emails.rb
58
+ - lib/oneview/api/sms.rb
113
59
  - lib/oneview/client.rb
60
+ - lib/oneview/entity/base.rb
114
61
  - lib/oneview/entity/contact.rb
115
62
  - lib/oneview/entity/dynamic_field.rb
63
+ - lib/oneview/entity/email.rb
116
64
  - lib/oneview/entity/phone.rb
65
+ - lib/oneview/entity/sms.rb
117
66
  - lib/oneview/version.rb
118
67
  - oneview.gemspec
119
68
  - spec/oneview/api/contacts_spec.rb
69
+ - spec/oneview/api/emails_spec.rb
70
+ - spec/oneview/api/sms_spec.rb
120
71
  - spec/oneview/client_spec.rb
121
72
  - spec/oneview/entity/contact_spec.rb
122
73
  - spec/oneview/entity/dynamic_field_spec.rb
74
+ - spec/oneview/entity/email_spec.rb
123
75
  - spec/oneview/entity/phone_spec.rb
76
+ - spec/oneview/entity/sms_spec.rb
124
77
  - spec/oneview_spec.rb
125
78
  - spec/spec_helper.rb
126
79
  homepage: https://github.com/coyosoftware/oneview
@@ -142,16 +95,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
95
  - !ruby/object:Gem::Version
143
96
  version: '0'
144
97
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.4.2
98
+ rubygems_version: 3.0.8
147
99
  signing_key:
148
100
  specification_version: 4
149
101
  summary: This gem provides integration with Oneview APIs (http://www.oneview.com.br/)
150
102
  test_files:
151
103
  - spec/oneview/api/contacts_spec.rb
104
+ - spec/oneview/api/emails_spec.rb
105
+ - spec/oneview/api/sms_spec.rb
152
106
  - spec/oneview/client_spec.rb
153
107
  - spec/oneview/entity/contact_spec.rb
154
108
  - spec/oneview/entity/dynamic_field_spec.rb
109
+ - spec/oneview/entity/email_spec.rb
155
110
  - spec/oneview/entity/phone_spec.rb
111
+ - spec/oneview/entity/sms_spec.rb
156
112
  - spec/oneview_spec.rb
157
113
  - spec/spec_helper.rb