Module: Voxbone
- Extended by:
- Config, Inventory, Ordering
- Includes:
- HTTParty
- Defined in:
- lib/voxbone/config.rb,
lib/voxbone/version.rb,
lib/voxbone/voxbone.rb,
lib/voxbone/ordering.rb,
lib/voxbone/inventory.rb
Defined Under Namespace
Modules: Config, Inventory, Ordering
Constant Summary
collapse
- VERSION =
'0.0.3'
{
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}.freeze
Constants included
from Config
Config::ENVIRONMENTS
Instance Attribute Summary
Attributes included from Config
#environment, #password, #username
Class Method Summary
collapse
Methods included from Config
configure
Methods included from Ordering
add_to_cart, checkout_cart, create_cart
Methods included from Inventory
list_did_group
Class Method Details
.auth ⇒ Object
44
45
46
|
# File 'lib/voxbone/voxbone.rb', line 44
def auth
{ username: username, password: password }
end
|
.camelize(string) ⇒ Object
38
39
40
41
42
|
# File 'lib/voxbone/voxbone.rb', line 38
def camelize(string)
parts = string.to_s.split('_')
transformed_parts = parts[1..-1].map(&:capitalize).unshift(parts[0])
transformed_parts.join
end
|
.camelize_keys(obj) ⇒ Object
33
34
35
36
|
# File 'lib/voxbone/voxbone.rb', line 33
def camelize_keys(obj)
return obj unless obj.is_a?(Hash)
Hash[obj.map { |key, value| [camelize(key), camelize_keys(value)] }]
end
|
.send_get(path, **options) ⇒ Object
13
14
15
16
17
|
# File 'lib/voxbone/voxbone.rb', line 13
def send_get(path, **options)
query = camelize_keys(options) if options
get(
path, query: query, headers: HEADERS, basic_auth: auth)
end
|
.send_post(path, **options) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/voxbone/voxbone.rb', line 26
def send_post(path, **options)
auth = { username: username, password: password }
query = camelize_keys(options)
post(
path, query: query, headers: HEADERS, basic_auth: auth)
end
|
.send_put(path, **options) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/voxbone/voxbone.rb', line 19
def send_put(path, **options)
auth = { username: username, password: password }
query = camelize_keys(options) if options
put(
path, query: query, headers: HEADERS, basic_auth: auth)
end
|