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.



217
218
219
220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 217

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



317
318
319
320
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 317

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

#to_sObject

Provide a user friendly representation



310
311
312
313
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 310

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:



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 234

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:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 271

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],
    )
    PaymentInstanceMetadata.new(
        @version,
        payment_instance,
        response.headers,
        response.status_code
    )
end