Class: Fog::Compute::Packet::PaymentMethod

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/packet/models/payment_method.rb

Overview

PaymentMethod Model

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PaymentMethod

Returns a new instance of PaymentMethod.



25
26
27
# File 'lib/fog/compute/packet/models/payment_method.rb', line 25

def initialize(attributes = {})
  super
end

Instance Method Details

#destroyObject



54
55
56
57
58
59
# File 'lib/fog/compute/packet/models/payment_method.rb', line 54

def destroy
  requires :id

  response = service.delete_payment_method(id)
  true if response.status == 204
end

#saveObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/compute/packet/models/payment_method.rb', line 29

def save
  requires :organization_id, :nonce, :name
  options = {
    :name => name,
    :nonce => nonce
  }
  options[:default] = default if default
  response = service.create_payment_method(organization_id, options)

  merge_attributes(response.body)
end

#updateObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/compute/packet/models/payment_method.rb', line 41

def update
  requires :id
  options = {}
  options[:name] = options["name"] if options["name"]
  options[:cardholder_name] = options["cardholder_name"] if options["cardholder_name"]
  options[:expiration_month] = options["expiration_month"] if options["expiration_month"]
  options[:expiration_year] = options["expiration_year"] if options["expiration_year"]

  response = service.update_payment_method(id, options)

  merge_attributes(response.body)
end