Class: KillBillClient::Model::Tenant

Inherits:
TenantAttributes show all
Defined in:
lib/killbill_client/models/tenant.rb

Constant Summary collapse

KILLBILL_API_TENANTS_PREFIX =
"#{KILLBILL_API_PREFIX}/tenants"

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

.delete_tenant_plugin_config(plugin_name, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



29
30
31
# File 'lib/killbill_client/models/tenant.rb', line 29

def delete_tenant_plugin_config(plugin_name, user = nil, reason = nil, comment = nil, options = {})
  delete_tenant_user_key_value(plugin_name, "uploadPluginConfig", "plugin config", user, reason, comment, options)
end

.delete_tenant_user_key_value(key_name, key_path, error_id_str, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



42
43
44
# File 'lib/killbill_client/models/tenant.rb', line 42

def delete_tenant_user_key_value(key_name, user = nil, reason = nil, comment = nil, options = {})
  delete_tenant_user_key_value(key_name, "userKeyValue", "tenant key/value", user, reason, comment, options)
end

.find_by_api_key(api_key, options = {}) ⇒ Object



15
16
17
18
19
# File 'lib/killbill_client/models/tenant.rb', line 15

def find_by_api_key(api_key, options = {})
  get "#{KILLBILL_API_TENANTS_PREFIX}/?apiKey=#{api_key}",
      {},
      options
end

.find_by_id(tenant_id, options = {}) ⇒ Object



9
10
11
12
13
# File 'lib/killbill_client/models/tenant.rb', line 9

def find_by_id(tenant_id, options = {})
  get "#{KILLBILL_API_TENANTS_PREFIX}/#{tenant_id}",
      {},
      options
end

.get_tenant_key_value(key_name, key_path, error_id_str, options = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/killbill_client/models/tenant.rb', line 46

def get_tenant_key_value(key_name, key_path, error_id_str, options = {})

  require_multi_tenant_options!(options, "Retrieving a #{error_id_str} is only supported in multi-tenant mode")

  uri =  KILLBILL_API_TENANTS_PREFIX + "/#{key_path}/" + key_name
  get uri,
      {},
      {
      }.merge(options),
      KillBillClient::Model::TenantKeyAttributes
end

.get_tenant_plugin_config(plugin_name, options = {}) ⇒ Object



21
22
23
# File 'lib/killbill_client/models/tenant.rb', line 21

def get_tenant_plugin_config(plugin_name, options = {})
  get_tenant_key_value(plugin_name, "uploadPluginConfig", "plugin config", options)
end

.get_tenant_user_key_value(key_name, options = {}) ⇒ Object



33
34
35
# File 'lib/killbill_client/models/tenant.rb', line 33

def get_tenant_user_key_value(key_name, options = {})
  get_tenant_key_value(key_name, "userKeyValue", "tenant key/value", options)
end

.upload_tenant_key_value(key_name, key_value, key_path, get_method, error_id_str, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/killbill_client/models/tenant.rb', line 59

def upload_tenant_key_value(key_name, key_value, key_path, get_method, error_id_str, user = nil, reason = nil, comment = nil, options = {})

  require_multi_tenant_options!(options, "Uploading a #{error_id_str} is only supported in multi-tenant mode")

  uri =  KILLBILL_API_TENANTS_PREFIX + "/#{key_path}/" + key_name
  post uri,
       key_value,
       {
       },
       {
           :content_type => 'text/plain',
           :user => user,
           :reason => reason,
           :comment => comment,
       }.merge(options)
  send(get_method.to_sym, key_name, options)
end

.upload_tenant_plugin_config(plugin_name, plugin_config, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



25
26
27
# File 'lib/killbill_client/models/tenant.rb', line 25

def upload_tenant_plugin_config(plugin_name, plugin_config, user = nil, reason = nil, comment = nil, options = {})
  upload_tenant_key_value(plugin_name, plugin_config, "uploadPluginConfig", "get_tenant_plugin_config", "plugin config", user, reason, comment, options)
end

.upload_tenant_user_key_value(key_name, key_value, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



37
38
39
# File 'lib/killbill_client/models/tenant.rb', line 37

def upload_tenant_user_key_value(key_name, key_value, user = nil, reason = nil, comment = nil, options = {})
  upload_tenant_key_value(key_name, key_value, "userKeyValue", "get_tenant_user_key_value", "tenant key/value", user, reason, comment, options)
end

Instance Method Details

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



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/killbill_client/models/tenant.rb', line 98

def create(user = nil, reason = nil, comment = nil, options = {})
  created_tenant = self.class.post KILLBILL_API_TENANTS_PREFIX,
                                   to_json,
                                   {},
                                   {
                                       :user => user,
                                       :reason => reason,
                                       :comment => comment,
                                   }.merge(options)
  #
  # Specify api_key and api_secret before making the call to retrieve the tenant object
  # otherwise that would fail with a 401
  #
  options[:api_key] = @api_key
  options[:api_secret] = @api_secret
  created_tenant.refresh(options)
end