oneview 0.0.1
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 +7 -0
- data/.gitignore +41 -0
- data/.travis.yml +16 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +10 -0
- data/lib/oneview.rb +36 -0
- data/lib/oneview/api/contacts.rb +21 -0
- data/lib/oneview/client.rb +50 -0
- data/lib/oneview/entity/contact.rb +30 -0
- data/lib/oneview/entity/dynamic_field.rb +17 -0
- data/lib/oneview/entity/phone.rb +17 -0
- data/lib/oneview/version.rb +3 -0
- data/oneview.gemspec +28 -0
- data/spec/oneview/api/contacts_spec.rb +53 -0
- data/spec/oneview/client_spec.rb +28 -0
- data/spec/oneview/entity/contact_spec.rb +35 -0
- data/spec/oneview/entity/dynamic_field_spec.rb +15 -0
- data/spec/oneview/entity/phone_spec.rb +16 -0
- data/spec/oneview_spec.rb +7 -0
- data/spec/spec_helper.rb +10 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 337b3c6c73272b1e4a069237f95499346f7b3619
|
4
|
+
data.tar.gz: 9e06ccc674980568d53415a18ac8e1e8577640ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c6ed23b47f36b2be135378138eb90c17748d4e014d0b3bb893f25a16f8de3fc471274f39b7ebf22a4756898e82fb38f00dad8c5621c7db6f0d38a0d383cc020a
|
7
|
+
data.tar.gz: 03fa1ea3b56b509cf05586c7dde79a26f79e9b3a2cff753179ca6642c955c99a072ee97548afbb7cc888bd48fe13e8543f872b353baa064f734254d0d3b74cd8
|
data/.gitignore
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.project
|
24
|
+
|
25
|
+
## Documentation cache and generated files:
|
26
|
+
/.yardoc/
|
27
|
+
/_yardoc/
|
28
|
+
/doc/
|
29
|
+
/rdoc/
|
30
|
+
|
31
|
+
## Environment normalisation:
|
32
|
+
/.bundle/
|
33
|
+
/lib/bundler/man/
|
34
|
+
|
35
|
+
# for a library or gem, you might want to ignore these files since the code is
|
36
|
+
# intended to run in multiple environments; otherwise, check them in:
|
37
|
+
# Gemfile.lock
|
38
|
+
# .ruby-version
|
39
|
+
# .ruby-gemset
|
40
|
+
|
41
|
+
.rvmrc
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
|
5
|
+
addons:
|
6
|
+
code_climate:
|
7
|
+
repo_token: 5b5c9617f7250055e1b48d7f1297c5b36a6861d9431607a8b310dc22dc046ba8
|
8
|
+
|
9
|
+
bundler_args: --without development
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- gberdugo@gmail.com
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Gustavo Berdugo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Oneview
|
2
|
+
|
3
|
+
[](https://travis-ci.org/coyosoftware/oneview) [](http://badge.fury.io/rb/oneview) [](https://codeclimate.com/github/coyosoftware/oneview) [](https://codeclimate.com/github/coyosoftware/oneview)
|
4
|
+
|
5
|
+
This gem simplifies the usage of [Oneview](http://www.oneview.com.br/) API
|
6
|
+
|
7
|
+
For more information regarding the API, visit the [documentation]
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'oneview'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install oneview
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Create a new instance of Oneview class passing your access token:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
client = Oneview.new(YOUR_ACCESS_TOKEN)
|
29
|
+
```
|
30
|
+
|
31
|
+
With the client instance, you can access the following resources:
|
32
|
+
|
33
|
+
* Contacts (client.contacts) **Only creation**
|
34
|
+
* Sms Sending (client.sms) **Not Implemented Yet**
|
35
|
+
* Email Sending (client.email) **Not Implemented Yet**
|
36
|
+
|
37
|
+
## Using the resources
|
38
|
+
### Creating new records
|
39
|
+
All resources implement a **create** method.
|
40
|
+
|
41
|
+
It can accept a hash with the parameters as described in the API [documentation] or an Entity object that reflects the API fields.
|
42
|
+
|
43
|
+
Currently the following entities are implemented:
|
44
|
+
|
45
|
+
* [Contact](lib/oneview/entity/contact.rb)
|
46
|
+
* [Phone](lib/oneview/entity/phone.rb)
|
47
|
+
* [Dynamic Field](lib/oneview/entity/dynamic_field.rb)
|
48
|
+
|
49
|
+
### Reading the response
|
50
|
+
All methods return an Oneview::Client::Response object. This objects contains the following attributes:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
response = Oneview.new(YOUR_ACCESS_TOKEN).contacts.create(contact_entity)
|
54
|
+
|
55
|
+
response.status # Contains the status code of the request
|
56
|
+
response.payload # Contains the return data (JSON) of the request
|
57
|
+
response.raw_response # Contains the HTTParty response object
|
58
|
+
```
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it ( https://github.com/coyosoftware/oneview/fork )
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create a new Pull Request
|
67
|
+
|
68
|
+
[documentation]: http://coyosoftware.github.io/
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
data/lib/oneview.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "oneview/version"
|
2
|
+
|
3
|
+
module Oneview
|
4
|
+
LIBNAME = 'oneview'
|
5
|
+
LIBDIR = File.expand_path("../#{LIBNAME}", __FILE__)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
def new(access_token)
|
13
|
+
Client.new(access_token)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
# Requires internal libraries
|
19
|
+
#
|
20
|
+
# @param [String] prefix
|
21
|
+
# the relative path prefix
|
22
|
+
# @param [Array[String]] libs
|
23
|
+
# the array of libraries to require
|
24
|
+
#
|
25
|
+
# @return [self]
|
26
|
+
def require_all(prefix, *libs)
|
27
|
+
libs.each do |lib|
|
28
|
+
require "#{File.join(prefix, lib)}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
extend ClassMethods
|
34
|
+
|
35
|
+
require_all LIBDIR, 'client'
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Oneview
|
2
|
+
module Api
|
3
|
+
class Contacts < Client
|
4
|
+
require_all 'oneview/entity', 'contact', 'dynamic_field', 'phone'
|
5
|
+
|
6
|
+
base_uri "http://www.oneview.com.br/api/contacts"
|
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::Contact)
|
11
|
+
raise ArgumentError
|
12
|
+
end
|
13
|
+
alias :new :create
|
14
|
+
|
15
|
+
private
|
16
|
+
def build_body(parameters)
|
17
|
+
super({:contact => parameters})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module Oneview
|
4
|
+
class Client
|
5
|
+
class NoAccessTokenError < StandardError
|
6
|
+
def message
|
7
|
+
"Please provide an access token"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
extend Oneview::ClassMethods
|
12
|
+
include HTTParty
|
13
|
+
|
14
|
+
require_all 'oneview/api', 'contacts'
|
15
|
+
|
16
|
+
attr_accessor :access_token
|
17
|
+
|
18
|
+
def initialize(access_token)
|
19
|
+
raise NoAccessTokenError if access_token.nil? || access_token.strip == ""
|
20
|
+
@access_token = access_token
|
21
|
+
end
|
22
|
+
|
23
|
+
def contacts
|
24
|
+
Oneview::Api::Contacts.new(@access_token)
|
25
|
+
end
|
26
|
+
|
27
|
+
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
|
39
|
+
|
40
|
+
class Response
|
41
|
+
attr_accessor :status, :payload, :raw_response
|
42
|
+
|
43
|
+
def initialize(response)
|
44
|
+
@status = response.code
|
45
|
+
@payload = response.parsed_response
|
46
|
+
@raw_response = response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Oneview
|
2
|
+
module Entity
|
3
|
+
class Contact
|
4
|
+
attr_accessor :id, :name, :birthday, :email, :city, :state, :zip_code, :address, :phone, :dynamic_fields
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.phone = Phone.new
|
8
|
+
self.dynamic_fields = Array.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def as_parameter
|
12
|
+
variables = instance_variables.map do |name|
|
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)]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
self.dynamic_fields.each do |dynamic_field|
|
23
|
+
variables << [dynamic_field.name, dynamic_field.value]
|
24
|
+
end
|
25
|
+
|
26
|
+
Hash[variables.compact]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Oneview
|
2
|
+
module Entity
|
3
|
+
class DynamicField
|
4
|
+
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
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Oneview
|
2
|
+
module Entity
|
3
|
+
class Phone
|
4
|
+
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
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/oneview.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'oneview/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "oneview"
|
8
|
+
spec.version = Oneview::VERSION
|
9
|
+
spec.authors = ["Gustavo Berdugo"]
|
10
|
+
spec.email = ["gberdugo@gmail.com"]
|
11
|
+
spec.summary = %q{This gem provides integration with Oneview APIs (http://www.oneview.com.br/)}
|
12
|
+
spec.description = %q{The goal of this gem is to simplify the access to Oneview API (http://www.oneview.com.br/), for more information about this API, visit: http://coyosoftware.github.io/}
|
13
|
+
spec.homepage = "https://github.com/coyosoftware/oneview"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency('httparty', "~> 0.13")
|
22
|
+
|
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
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Api::Contacts do
|
4
|
+
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
|
+
|
8
|
+
before(:each) do
|
9
|
+
dynamic_field = Oneview::Entity::DynamicField.new
|
10
|
+
dynamic_field.name = "dynamic_field"
|
11
|
+
dynamic_field.value = "123"
|
12
|
+
|
13
|
+
phone = Oneview::Entity::Phone.new
|
14
|
+
phone.country_code = "+55"
|
15
|
+
phone.area_code = "12"
|
16
|
+
phone.number = "998998789"
|
17
|
+
|
18
|
+
@contact = Oneview::Entity::Contact.new
|
19
|
+
@contact.name = "name"
|
20
|
+
@contact.email = "email@email.com"
|
21
|
+
@contact.birthday = "14/10/2014"
|
22
|
+
@contact.city = "city"
|
23
|
+
@contact.state = "state"
|
24
|
+
@contact.zip_code = "12233-444"
|
25
|
+
@contact.phone = phone
|
26
|
+
@contact.dynamic_fields << dynamic_field
|
27
|
+
|
28
|
+
stub_request(:post, "http://www.oneview.com.br/api/contacts/").to_return(:status => 200)
|
29
|
+
end
|
30
|
+
|
31
|
+
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
|
34
|
+
|
35
|
+
Oneview.new("abc").contacts.create({:name => "name", :email => "email"})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
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
|
42
|
+
|
43
|
+
Oneview.new("abc").contacts.create(@contact)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
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)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Client do
|
4
|
+
before(:each) do
|
5
|
+
Oneview::Client.send(:public, *Oneview::Client.protected_instance_methods)
|
6
|
+
end
|
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")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the correct headers" do
|
13
|
+
expect(Oneview::Client.new("abc").header).to eq({"Content-Type" => "application/json", "Accept" => "application/json"})
|
14
|
+
end
|
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)
|
18
|
+
end
|
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)
|
22
|
+
|
23
|
+
response = Oneview.new("abc").contacts.create({:name => "name"})
|
24
|
+
|
25
|
+
expect(response.class).to eq(Oneview::Client::Response)
|
26
|
+
expect(response.status).to eq(200)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Entity::Contact do
|
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"}}
|
8
|
+
|
9
|
+
it "should return the contact as parameter" do
|
10
|
+
contact = Oneview::Entity::Contact.new
|
11
|
+
|
12
|
+
contact.name = "name"
|
13
|
+
contact.email = "email@email.com"
|
14
|
+
contact.birthday = "14/10/2014"
|
15
|
+
contact.city = "city"
|
16
|
+
contact.state = "state"
|
17
|
+
contact.zip_code = "12233-444"
|
18
|
+
|
19
|
+
phone = Oneview::Entity::Phone.new
|
20
|
+
phone.country_code = "+55"
|
21
|
+
phone.area_code = "12"
|
22
|
+
phone.number = "998998789"
|
23
|
+
|
24
|
+
contact.phone = phone
|
25
|
+
|
26
|
+
dynamic_field = Oneview::Entity::DynamicField.new
|
27
|
+
dynamic_field.name = "dynamic_field"
|
28
|
+
dynamic_field.value = "123"
|
29
|
+
|
30
|
+
contact.dynamic_fields << dynamic_field
|
31
|
+
|
32
|
+
expect(contact.as_parameter).to eq(contact_as_parameter)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Entity::DynamicField do
|
4
|
+
describe "as_parameter" do
|
5
|
+
let(:dynamic_field_as_parameter) {{"name" => "dynamic_field", "value" => "abc"}}
|
6
|
+
|
7
|
+
it "should return the dynamic_field as parameter" do
|
8
|
+
dynamic_field = Oneview::Entity::DynamicField.new
|
9
|
+
dynamic_field.name = "dynamic_field"
|
10
|
+
dynamic_field.value = "abc"
|
11
|
+
|
12
|
+
expect(dynamic_field.as_parameter).to eq(dynamic_field_as_parameter)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Oneview::Entity::Phone do
|
4
|
+
describe "as_parameter" do
|
5
|
+
let(:phone_as_parameter) {{"number" => "999999999", "area_code" => "12", "country_code" => "+55"}}
|
6
|
+
|
7
|
+
it "should return the phone as parameter" do
|
8
|
+
phone = Oneview::Entity::Phone.new
|
9
|
+
phone.country_code = "+55"
|
10
|
+
phone.area_code = "12"
|
11
|
+
phone.number = "999999999"
|
12
|
+
|
13
|
+
expect(phone.as_parameter).to eq(phone_as_parameter)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oneview
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gustavo Berdugo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
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
|
+
description: 'The goal of this gem is to simplify the access to Oneview API (http://www.oneview.com.br/),
|
98
|
+
for more information about this API, visit: http://coyosoftware.github.io/'
|
99
|
+
email:
|
100
|
+
- gberdugo@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/oneview.rb
|
112
|
+
- lib/oneview/api/contacts.rb
|
113
|
+
- lib/oneview/client.rb
|
114
|
+
- lib/oneview/entity/contact.rb
|
115
|
+
- lib/oneview/entity/dynamic_field.rb
|
116
|
+
- lib/oneview/entity/phone.rb
|
117
|
+
- lib/oneview/version.rb
|
118
|
+
- oneview.gemspec
|
119
|
+
- spec/oneview/api/contacts_spec.rb
|
120
|
+
- spec/oneview/client_spec.rb
|
121
|
+
- spec/oneview/entity/contact_spec.rb
|
122
|
+
- spec/oneview/entity/dynamic_field_spec.rb
|
123
|
+
- spec/oneview/entity/phone_spec.rb
|
124
|
+
- spec/oneview_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
homepage: https://github.com/coyosoftware/oneview
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.4.2
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: This gem provides integration with Oneview APIs (http://www.oneview.com.br/)
|
150
|
+
test_files:
|
151
|
+
- spec/oneview/api/contacts_spec.rb
|
152
|
+
- spec/oneview/client_spec.rb
|
153
|
+
- spec/oneview/entity/contact_spec.rb
|
154
|
+
- spec/oneview/entity/dynamic_field_spec.rb
|
155
|
+
- spec/oneview/entity/phone_spec.rb
|
156
|
+
- spec/oneview_spec.rb
|
157
|
+
- spec/spec_helper.rb
|