voxbone-ruby 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +39 -0
- data/README.md +9 -0
- data/lib/voxbone/config.rb +29 -0
- data/lib/voxbone/inventory.rb +59 -0
- data/lib/voxbone/version.rb +3 -0
- data/lib/voxbone/voxbone.rb +30 -0
- data/lib/voxbone.rb +5 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/voxbone/inventory_spec.rb +14 -0
- data/voxbone-ruby.gemspec +22 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe08e01083e7a6fe667dc820b5d8f35059d74ce5
|
4
|
+
data.tar.gz: f8f4e1d57a3610ccd10207f2b5d03b5e43bb5574
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7cce10925e258517cc299633a41436ddf6b57feee641ecc40c00682fd213a8af1526ce9df12c4fce7af4b46585d44508ec9eee7d2a505753e6c130657e9a68a9
|
7
|
+
data.tar.gz: fda26751c9ea902abccbbd6f2d2c0765a7e2a583cb35afc6b70f8533ec64b12042140349297b4898b85e13ab0422de279769bde72d26c14f8c9535a60de09459
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
voxbone-ruby-*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
voxbone-ruby (0.0.1)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
httparty (0.13.7)
|
12
|
+
json (~> 1.8)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
json (1.8.3)
|
15
|
+
multi_xml (0.5.5)
|
16
|
+
rspec (3.4.0)
|
17
|
+
rspec-core (~> 3.4.0)
|
18
|
+
rspec-expectations (~> 3.4.0)
|
19
|
+
rspec-mocks (~> 3.4.0)
|
20
|
+
rspec-core (3.4.2)
|
21
|
+
rspec-support (~> 3.4.0)
|
22
|
+
rspec-expectations (3.4.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.4.0)
|
25
|
+
rspec-mocks (3.4.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.4.0)
|
28
|
+
rspec-support (3.4.1)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler
|
35
|
+
rspec (~> 3.0)
|
36
|
+
voxbone-ruby!
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Voxbone
|
2
|
+
module Config
|
3
|
+
attr_accessor :username, :password, :environment
|
4
|
+
|
5
|
+
ENVIRONMENTS = {
|
6
|
+
production: 'https://api.voxbone.com/ws-voxbone/services/rest/',
|
7
|
+
sandbox: 'https://sandbox.voxbone.com/ws-voxbone/services/rest/'
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
class ConfigError < StandardError; end
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def environment=(environment_name)
|
17
|
+
environment_name = environment_name.to_sym
|
18
|
+
Voxbone.base_uri ENVIRONMENTS.fetch environment_name
|
19
|
+
@environment = environment_name
|
20
|
+
rescue KeyError
|
21
|
+
raise(
|
22
|
+
ConfigError,
|
23
|
+
"#{environment_name} is not a valid environment. Instead, use one of " \
|
24
|
+
"the following: #{ENVIRONMENTS.keys}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
extend Config
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Voxbone
|
2
|
+
module Inventory
|
3
|
+
# List DID Group
|
4
|
+
#
|
5
|
+
# `list_did_group` allows you to retrieve the list of DID groups. A DID
|
6
|
+
# group can be defined as the smallest set of DIDs which is usually DIDs
|
7
|
+
# that share the same city or area code attributes. It is a method which is
|
8
|
+
# useful to get pricing info on a DID and to get didGroupIds which is a
|
9
|
+
# required parameter when placing a DID order.
|
10
|
+
#
|
11
|
+
# options - Type: Hash. Parameters used to refine the selection.
|
12
|
+
# :country_code_a3 - Type: String. Indicates the country code of
|
13
|
+
# the DID group in its ISO 3166-1 alpha-3
|
14
|
+
# format (e.g. "GBR" for United Kingdom,
|
15
|
+
# "USA" for United States of America, "BEL"
|
16
|
+
# for Belgium, etc.). (required)
|
17
|
+
# :page_number - Type: Integer. The page number, starting at
|
18
|
+
# 0. (required)
|
19
|
+
# :page_size - Type: Integer. The page size (max number of
|
20
|
+
# entities that are displayed in the
|
21
|
+
# response). (required)
|
22
|
+
# :did_group_ids - Type: Integer (multiple). Can be used if
|
23
|
+
# you want information about specific DID
|
24
|
+
# groups.
|
25
|
+
# :state_id - Type: String. The numerical identifier for
|
26
|
+
# the didGroup's state. Please see the
|
27
|
+
# `list_state` operation to retrieve a valid
|
28
|
+
# state identifier.
|
29
|
+
# :city_name_pattern - Type: String. A string pattern for the
|
30
|
+
# beginning of city name: "New York%" will
|
31
|
+
# return all New York DID groups. On the
|
32
|
+
# contrary, "w York%" will return none.
|
33
|
+
# :rate_center - Type: String. The rate center can be
|
34
|
+
# defined as a zone (which can be equivalent
|
35
|
+
# to a city or the area of a city) e.g. the
|
36
|
+
# rate center of "NEW YORK CITY ZONE 1" would
|
37
|
+
# be "NWYRCYZN01". The rate center is a
|
38
|
+
# notion usually used in north America.
|
39
|
+
# :area_code - Type: String. The area code of the DID
|
40
|
+
# group (e.g. "646").
|
41
|
+
# :did_type - Type: String. The type of DID. The possible
|
42
|
+
# values are GEOGRAPHIC, TOLL_FREE, NATIONAL,
|
43
|
+
# MOBILE, SHARED_COST, SPECIAL, or INUM.
|
44
|
+
# :show_empty - Type: Boolean. Set to true if you want to
|
45
|
+
# show the didGroups with no stock currently
|
46
|
+
# available.
|
47
|
+
# :feature_ids - Type: Integer (multiple). Can be used if
|
48
|
+
# you want to list DID groups that support
|
49
|
+
# certain features such as VoxSMS or VoxFAX.
|
50
|
+
# (eg. 6 for VoxFAX, 25 for VoxSMS). Note
|
51
|
+
# that you can specify multiple features by
|
52
|
+
# repeating the query parameter.
|
53
|
+
def list_did_group(**options)
|
54
|
+
get('/inventory/didgroup', options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
extend Inventory
|
59
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Voxbone
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
HEADERS = {
|
8
|
+
'Content-Type' => 'application/json',
|
9
|
+
'Accept' => 'application/json'
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def get(path, **options)
|
14
|
+
auth = { username: username, password: password }
|
15
|
+
query = camelize_keys(options) if options
|
16
|
+
super(
|
17
|
+
path, query: query, headers: HEADERS, basic_auth: auth)
|
18
|
+
end
|
19
|
+
|
20
|
+
def camelize_keys(hash)
|
21
|
+
Hash[hash.map { |key, value| [camelize(key), value] }]
|
22
|
+
end
|
23
|
+
|
24
|
+
def camelize(string)
|
25
|
+
parts = string.to_s.split('_')
|
26
|
+
transformed_parts = parts[1..-1].map(&:capitalize).unshift(parts[0])
|
27
|
+
transformed_parts.join
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/voxbone.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Voxbone::Inventory do
|
4
|
+
describe '#list_did_group' do
|
5
|
+
it 'correctly makes the request' do
|
6
|
+
expect(Voxbone).to receive(:get).with(
|
7
|
+
'/inventory/didgroup',
|
8
|
+
country_code_a3: 'USA', page_number: 0, page_size: 5, area_code: '225')
|
9
|
+
|
10
|
+
Voxbone.list_did_group(
|
11
|
+
country_code_a3: 'USA', page_number: 0, page_size: 5, area_code: '225')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/voxbone/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'voxbone-ruby'
|
6
|
+
s.authors = ['Julien Negrotto']
|
7
|
+
s.email = ['jtnegrotto@gmail.com']
|
8
|
+
s.summary = "A gem for interacting with Voxbone's REST API."
|
9
|
+
s.description = "A gem for interacting with Voxbone's REST API"
|
10
|
+
s.homepage = ''
|
11
|
+
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- spec`.split("\n")
|
15
|
+
s.require_paths = ['lib']
|
16
|
+
s.version = Voxbone::VERSION
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'httparty'
|
19
|
+
|
20
|
+
s.add_development_dependency 'bundler'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: voxbone-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julien Negrotto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: A gem for interacting with Voxbone's REST API
|
56
|
+
email:
|
57
|
+
- jtnegrotto@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- lib/voxbone.rb
|
67
|
+
- lib/voxbone/config.rb
|
68
|
+
- lib/voxbone/inventory.rb
|
69
|
+
- lib/voxbone/version.rb
|
70
|
+
- lib/voxbone/voxbone.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spec/voxbone/inventory_spec.rb
|
73
|
+
- voxbone-ruby.gemspec
|
74
|
+
homepage: ''
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A gem for interacting with Voxbone's REST API.
|
97
|
+
test_files:
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/voxbone/inventory_spec.rb
|
100
|
+
has_rdoc:
|