Class: Retell::SDK::Unofficial::API::PhoneNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/retell/sdk/unofficial/api/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PhoneNumber

Returns a new instance of PhoneNumber.



6
7
8
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#create(area_code: nil, inbound_agent_id: nil, inbound_agent: nil, nickname: nil, outbound_agent_id: nil, outbound_agent: nil, extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 10

def create(
  area_code: nil,
  inbound_agent_id: nil,
  inbound_agent: nil,
  nickname: nil,
  outbound_agent_id: nil,
  outbound_agent: nil,
  extra_headers: nil,
  extra_query: nil,
  extra_body: nil,
  timeout: nil
)
  inbound_agent_id = inbound_agent_id || inbound_agent
  outbound_agent_id = outbound_agent_id || outbound_agent

  inbound_agent_id = inbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? inbound_agent_id.agent_id : inbound_agent_id
  outbound_agent_id = outbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? outbound_agent_id.agent_id : outbound_agent_id

  payload = {
    area_code: area_code,
    inbound_agent_id: inbound_agent_id,
    nickname: nickname,
    outbound_agent_id: outbound_agent_id
  }.compact

  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.post('/create-phone-number', payload, **options)
end

#delete(phone_number, extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 151

def delete(
  phone_number,
  extra_headers: nil,
  extra_query: nil,
  extra_body: nil,
  timeout: nil
)
  phone_number = phone_number.is_a?(Retell::SDK::Unofficial::PhoneNumber) ? phone_number.phone_number : phone_number

  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.delete("/delete-phone-number/#{phone_number}", **options)
end

#import(phone_number, termination_uri:, inbound_agent_id: nil, inbound_agent: nil, nickname: nil, outbound_agent_id: nil, outbound_agent: nil, sip_trunk_auth_password: nil, sip_trunk_auth_username: nil, extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 45

def import(
  phone_number,
  termination_uri:,
  inbound_agent_id: nil,
  inbound_agent: nil,
  nickname: nil,
  outbound_agent_id: nil,
  outbound_agent: nil,
  sip_trunk_auth_password: nil,
  sip_trunk_auth_username: nil,
  extra_headers: nil,
  extra_query: nil,
  extra_body: nil,
  timeout: nil
)
  inbound_agent_id = inbound_agent_id || inbound_agent
  outbound_agent_id = outbound_agent_id || outbound_agent

  inbound_agent_id = inbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? inbound_agent_id.agent_id : inbound_agent_id
  outbound_agent_id = outbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? outbound_agent_id.agent_id : outbound_agent_id

  payload = {
    phone_number: phone_number,
    termination_uri: termination_uri,
    inbound_agent_id: inbound_agent_id,
    nickname: nickname,
    outbound_agent_id: outbound_agent_id,
    sip_trunk_auth_password: sip_trunk_auth_password,
    sip_trunk_auth_username: sip_trunk_auth_username
  }.compact

  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.post('/import-phone-number', payload, **options)
end

#list(extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



105
106
107
108
109
110
111
112
113
114
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 105

def list(extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil)
  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.get('/list-phone-numbers', **options)
end

#retrieve(phone_number, extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 86

def retrieve(
  phone_number,
  extra_headers: nil,
  extra_query: nil,
  extra_body: nil,
  timeout: nil
)
  phone_number = phone_number.is_a?(Retell::SDK::Unofficial::PhoneNumber) ? phone_number.phone_number : phone_number

  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.get("/get-phone-number/#{phone_number}", **options)
end

#update(phone_number, inbound_agent_id: nil, inbound_agent: nil, nickname: nil, outbound_agent_id: nil, outbound_agent: nil, extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/retell/sdk/unofficial/api/phone_number.rb', line 116

def update(
  phone_number,
  inbound_agent_id: nil,
  inbound_agent: nil,
  nickname: nil,
  outbound_agent_id: nil,
  outbound_agent: nil,
  extra_headers: nil,
  extra_query: nil,
  extra_body: nil,
  timeout: nil
)
  inbound_agent_id = inbound_agent_id || inbound_agent
  outbound_agent_id = outbound_agent_id || outbound_agent

  phone_number = phone_number.is_a?(Retell::SDK::Unofficial::PhoneNumber) ? phone_number.phone_number : phone_number
  inbound_agent_id = inbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? inbound_agent_id.agent_id : inbound_agent_id
  outbound_agent_id = outbound_agent_id.is_a?(Retell::SDK::Unofficial::Agent) ? outbound_agent_id.agent_id : outbound_agent_id

  payload = {
    inbound_agent_id: inbound_agent_id,
    nickname: nickname,
    outbound_agent_id: outbound_agent_id
  }.compact

  options = @client.make_request_options(
    extra_headers: extra_headers,
    extra_query: extra_query,
    extra_body: extra_body,
    timeout: timeout
  )

  @client.patch("/update-phone-number/#{phone_number}", payload, **options)
end