Class: KillBillClient::Model::PaymentMethod

Inherits:
PaymentMethodAttributes show all
Defined in:
lib/killbill_client/models/payment_method.rb

Constant Summary collapse

KILLBILL_API_PAYMENT_METHODS_PREFIX =
"#{KILLBILL_API_PREFIX}/paymentMethods"
EXTERNAL_PAYMENT =
'__EXTERNAL_PAYMENT__'.freeze

Constants inherited from Resource

Resource::KILLBILL_API_PAGINATION_PREFIX, Resource::KILLBILL_API_PREFIX

Instance Attribute Summary

Attributes inherited from Resource

#clazz, #etag, #response, #session_id, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, #initialize, instantiate_record_from_json, post, put, #refresh, require_multi_tenant_options!, #to_hash, #to_json

Constructor Details

This class inherits a constructor from KillBillClient::Model::Resource

Class Method Details

.destroy(payment_method_id, set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/killbill_client/models/payment_method.rb', line 55

def destroy(payment_method_id, set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {})
  delete "#{KILLBILL_API_PAYMENT_METHODS_PREFIX}/#{payment_method_id}",
         {},
         {
             :deleteDefaultPmWithAutoPayOff => set_auto_pay_off
         },
         {
             :user => user,
             :reason => reason,
             :comment => comment,
         }.merge(options)
end

.find_all_by_account_id(account_id, with_plugin_info = false, options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/killbill_client/models/payment_method.rb', line 18

def (, with_plugin_info = false, options = {})
  get "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/paymentMethods",
      {
          :withPluginInfo => with_plugin_info
      },
      options
end

.find_by_id(payment_method_id, with_plugin_info = false, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/killbill_client/models/payment_method.rb', line 10

def find_by_id(payment_method_id, with_plugin_info = false, options = {})
  get "#{KILLBILL_API_PAYMENT_METHODS_PREFIX}/#{payment_method_id}",
      {
          :withPluginInfo => with_plugin_info
      },
      options
end

.find_in_batches(offset = 0, limit = 100, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/killbill_client/models/payment_method.rb', line 26

def find_in_batches(offset = 0, limit = 100, options = {})
  get "#{KILLBILL_API_PAYMENT_METHODS_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
      {
          :offset => offset,
          :limit => limit
      },
      options
end

.find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/killbill_client/models/payment_method.rb', line 35

def find_in_batches_by_search_key(search_key, offset = 0, limit = 100, options = {})
  get "#{KILLBILL_API_PAYMENT_METHODS_PREFIX}/search/#{search_key}",
      {
          :offset => offset,
          :limit => limit
      },
      options
end

.set_default(payment_method_id, account_id, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/killbill_client/models/payment_method.rb', line 44

def set_default(payment_method_id, , user = nil, reason = nil, comment = nil, options = {})
  put "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/paymentMethods/#{payment_method_id}/setDefault",
      nil,
      {},
      {
          :user => user,
          :reason => reason,
          :comment => comment,
      }.merge(options)
end

Instance Method Details

#create(is_default, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/killbill_client/models/payment_method.rb', line 69

def create(is_default, user = nil, reason = nil, comment = nil, options = {})
  created_pm = self.class.post "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{}/paymentMethods",
                               to_json,
                               {
                                   :isDefault => is_default
                               },
                               {
                                   :user => user,
                                   :reason => reason,
                                   :comment => comment,
                               }.merge(options)
  created_pm.refresh(options)
end

#destroy(set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



83
84
85
# File 'lib/killbill_client/models/payment_method.rb', line 83

def destroy(set_auto_pay_off = false, user = nil, reason = nil, comment = nil, options = {})
  self.class.destroy(payment_method_id, set_auto_pay_off, user, reason, comment, options)
end

#plugin_info=(info) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/killbill_client/models/payment_method.rb', line 87

def plugin_info=(info)
  @plugin_info = PaymentMethodPluginDetailAttributes.new
  @plugin_info.properties = []
  return if info.nil?

  if info['properties'].nil?
    # Convenience method to create properties to add a payment method
    info.each do |key, value|
      property = PluginPropertyAttributes.new
      property.key = key
      property.value = value
      property.is_updatable = false
      @plugin_info.properties << property
    end
  else
    # De-serialization from JSON payload
    info['properties'].each do |property_json|
      property = PluginPropertyAttributes.new
      property.key = property_json['key']
      property.value = property_json['value']
      property.is_updatable = property_json['isUpdatable']
      @plugin_info.properties << property
    end
  end
end