Class: Twilio::REST::Api::V2010::AccountContext::CallContext::PaymentContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/call/payment.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, call_sid, sid) ⇒ PaymentContext

Initialize the PaymentContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that will update the resource.

  • call_sid (String)

    The SID of the call that will update the resource. This should be the same call sid that was used to create payments resource.

  • sid (String)

    The SID of Payments session that needs to be updated.



205
206
207
208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 205

def initialize(version, , call_sid, sid)
    super(version)
    

    # Path Solution
    @solution = { account_sid: , call_sid: call_sid, sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Payments/#{@solution[:sid]}.json"

    
end

Instance Method Details

#inspectObject

Provide a detailed, user friendly representation



305
306
307
308
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 305

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.PaymentContext #{context}>"
end

#to_sObject

Provide a user friendly representation



298
299
300
301
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 298

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.PaymentContext #{context}>"
end

#update(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset) ⇒ PaymentInstance

Update the PaymentInstance

Parameters:

Returns:



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 222

def update(
    idempotency_key: nil, 
    status_callback: nil, 
    capture: :unset, 
    status: :unset
)

    data = Twilio::Values.of({
        'IdempotencyKey' => idempotency_key,
        'StatusCallback' => status_callback,
        'Capture' => capture,
        'Status' => status,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    PaymentInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        call_sid: @solution[:call_sid],
        sid: @solution[:sid],
    )
end

#update_with_metadata(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset) ⇒ PaymentInstance

Update the PaymentInstanceMetadata

Parameters:

Returns:



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 259

def (
  idempotency_key: nil, 
  status_callback: nil, 
  capture: :unset, 
  status: :unset
)

    data = Twilio::Values.of({
        'IdempotencyKey' => idempotency_key,
        'StatusCallback' => status_callback,
        'Capture' => capture,
        'Status' => status,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    payment_instance = PaymentInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        call_sid: @solution[:call_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        payment_instance,
        response.headers,
        response.status_code
    )
end