Module: DIDWW::Client

Defined in:
lib/didww/client.rb

Constant Summary collapse

BASE_URLS =
{
  sandbox: 'https://sandbox-api.didww.com/v3/'.freeze,
  production: 'https://api.didww.com/v3/'.freeze
}.freeze
DEFAULT_MODE =
:sandbox

Class Method Summary collapse

Class Method Details

.address_verificationsObject



142
143
144
# File 'lib/didww/client.rb', line 142

def address_verifications
  Resource::AddressVerification
end

.addressesObject



130
131
132
# File 'lib/didww/client.rb', line 130

def addresses
  Resource::Address
end

.api_base_urlObject



46
47
48
# File 'lib/didww/client.rb', line 46

def api_base_url
  ENV['DIDWW_API_URL'].presence || BASE_URLS[api_mode]
end

.api_keyObject



30
31
32
# File 'lib/didww/client.rb', line 30

def api_key
  @@api_key
end

.api_modeObject



26
27
28
# File 'lib/didww/client.rb', line 26

def api_mode
  @@api_mode || DEFAULT_MODE
end

.api_mode=(arg) ⇒ Object



150
151
152
153
154
155
# File 'lib/didww/client.rb', line 150

def api_mode=(arg)
  unless BASE_URLS.keys.include?(arg)
    raise ArgumentError.new("Mode should be in #{BASE_URLS.keys} (given '#{arg}').")
  end
  @@api_mode = arg
end

.api_versionObject



34
35
36
# File 'lib/didww/client.rb', line 34

def api_version
  @@api_version
end

.available_didsObject



110
111
112
# File 'lib/didww/client.rb', line 110

def available_dids
  Resource::AvailableDid
end

.balanceObject



50
51
52
# File 'lib/didww/client.rb', line 50

def balance
  Resource::Balance.all.first
end

.capacity_poolsObject



54
55
56
# File 'lib/didww/client.rb', line 54

def capacity_pools
  Resource::CapacityPool
end

.citiesObject



66
67
68
# File 'lib/didww/client.rb', line 66

def cities
  Resource::City
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (DIDWW::Client)

    the object that the method was called on



19
20
21
22
23
24
# File 'lib/didww/client.rb', line 19

def configure
  yield self if block_given?
  connect!
  require_didww_resources
  self
end

.countriesObject



70
71
72
# File 'lib/didww/client.rb', line 70

def countries
  Resource::Country
end

.did_group_typesObject



74
75
76
# File 'lib/didww/client.rb', line 74

def did_group_types
  Resource::DidGroupType
end

.did_groupsObject



78
79
80
# File 'lib/didww/client.rb', line 78

def did_groups
  Resource::DidGroup
end

.did_reservationsObject



114
115
116
# File 'lib/didww/client.rb', line 114

def did_reservations
  Resource::DidReservation
end

.didsObject



82
83
84
# File 'lib/didww/client.rb', line 82

def dids
  Resource::Did
end

.encrypted_fileObject



138
139
140
# File 'lib/didww/client.rb', line 138

def encrypted_file
  Resource::EncryptedFile
end

.exportsObject



58
59
60
# File 'lib/didww/client.rb', line 58

def exports
  Resource::Export
end

.identitiesObject



122
123
124
# File 'lib/didww/client.rb', line 122

def identities
  Resource::Identity
end

.nanpa_prefixesObject



157
158
159
# File 'lib/didww/client.rb', line 157

def nanpa_prefixes
  Resource::NanpaPrefix
end

.ordersObject



86
87
88
# File 'lib/didww/client.rb', line 86

def orders
  Resource::Order
end

.permanent_supporting_documentsObject



134
135
136
# File 'lib/didww/client.rb', line 134

def permanent_supporting_documents
  Resource::PermanentSupportingDocument
end

.popsObject



90
91
92
# File 'lib/didww/client.rb', line 90

def pops
  Resource::Pop
end

.proofsObject



126
127
128
# File 'lib/didww/client.rb', line 126

def proofs
  Resource::Proof
end

.regionsObject



94
95
96
# File 'lib/didww/client.rb', line 94

def regions
  Resource::Region
end

.requirement_validationObject



146
147
148
# File 'lib/didww/client.rb', line 146

def requirement_validation
  Resource::RequirementValidation
end

.requirementsObject



118
119
120
# File 'lib/didww/client.rb', line 118

def requirements
  Resource::Requirement
end

.shared_capacity_groupsObject



62
63
64
# File 'lib/didww/client.rb', line 62

def shared_capacity_groups
  Resource::SharedCapacityGroup
end

.voice_in_trunk_groupsObject



98
99
100
# File 'lib/didww/client.rb', line 98

def voice_in_trunk_groups
  Resource::VoiceInTrunkGroup
end

.voice_in_trunksObject



102
103
104
# File 'lib/didww/client.rb', line 102

def voice_in_trunks
  Resource::VoiceInTrunk
end

.voice_out_trunksObject



106
107
108
# File 'lib/didww/client.rb', line 106

def voice_out_trunks
  Resource::VoiceOutTrunk
end

.with_api_version(api_version) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/didww/client.rb', line 38

def with_api_version(api_version)
  old_api_version = self.api_version
  self.api_version = api_version
  yield
ensure
  self.api_version = old_api_version
end