Class: ChargeBee::Export

Inherits:
Model
  • Object
show all
Defined in:
lib/chargebee/models/export.rb

Defined Under Namespace

Classes: Download

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

construct, #init_dependant, #init_dependant_list, #initialize, #inspect, #load, #method_missing, #replace_white_space_with_underscore, #respond_to_missing?, #to_s, uri_path

Constructor Details

This class inherits a constructor from ChargeBee::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ChargeBee::Model

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def created_at
  @created_at
end

#downloadObject

Returns the value of attribute download.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def download
  @download
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def id
  @id
end

#mime_typeObject

Returns the value of attribute mime_type.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def mime_type
  @mime_type
end

#operation_typeObject

Returns the value of attribute operation_type.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def operation_type
  @operation_type
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/chargebee/models/export.rb', line 8

def status
  @status
end

Class Method Details

.addons(params = {}, env = nil, headers = {}) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/chargebee/models/export.rb', line 73

def self.addons(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","addons"), params, env, headers,nil, false, jsonKeys, options)
end

.attached_items(params = {}, env = nil, headers = {}) ⇒ Object



172
173
174
175
176
177
178
179
# File 'lib/chargebee/models/export.rb', line 172

def self.attached_items(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","attached_items"), params, env, headers,nil, false, jsonKeys, options)
end

.coupons(params = {}, env = nil, headers = {}) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/chargebee/models/export.rb', line 82

def self.coupons(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","coupons"), params, env, headers,nil, false, jsonKeys, options)
end

.credit_notes(params = {}, env = nil, headers = {}) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/chargebee/models/export.rb', line 118

def self.credit_notes(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","credit_notes"), params, env, headers,nil, false, jsonKeys, options)
end

.customers(params = {}, env = nil, headers = {}) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/chargebee/models/export.rb', line 91

def self.customers(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","customers"), params, env, headers,nil, false, jsonKeys, options)
end

.deferred_revenue(params, env = nil, headers = {}) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/chargebee/models/export.rb', line 55

def self.deferred_revenue(params, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","deferred_revenue"), params, env, headers,nil, false, jsonKeys, options)
end

.differential_prices(params = {}, env = nil, headers = {}) ⇒ Object



181
182
183
184
185
186
187
188
# File 'lib/chargebee/models/export.rb', line 181

def self.differential_prices(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","differential_prices"), params, env, headers,nil, false, jsonKeys, options)
end

.invoices(params = {}, env = nil, headers = {}) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/chargebee/models/export.rb', line 109

def self.invoices(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","invoices"), params, env, headers,nil, false, jsonKeys, options)
end

.item_families(params = {}, env = nil, headers = {}) ⇒ Object



145
146
147
148
149
150
151
152
# File 'lib/chargebee/models/export.rb', line 145

def self.item_families(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","item_families"), params, env, headers,nil, false, jsonKeys, options)
end

.item_prices(params = {}, env = nil, headers = {}) ⇒ Object



163
164
165
166
167
168
169
170
# File 'lib/chargebee/models/export.rb', line 163

def self.item_prices(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","item_prices"), params, env, headers,nil, false, jsonKeys, options)
end

.items(params = {}, env = nil, headers = {}) ⇒ Object



154
155
156
157
158
159
160
161
# File 'lib/chargebee/models/export.rb', line 154

def self.items(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","items"), params, env, headers,nil, false, jsonKeys, options)
end

.orders(params = {}, env = nil, headers = {}) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/chargebee/models/export.rb', line 136

def self.orders(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","orders"), params, env, headers,nil, false, jsonKeys, options)
end

.plans(params = {}, env = nil, headers = {}) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/chargebee/models/export.rb', line 64

def self.plans(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","plans"), params, env, headers,nil, false, jsonKeys, options)
end

.price_variants(params = {}, env = nil, headers = {}) ⇒ Object



190
191
192
193
194
195
196
197
# File 'lib/chargebee/models/export.rb', line 190

def self.price_variants(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","price_variants"), params, env, headers,nil, false, jsonKeys, options)
end

.retrieve(id, env = nil, headers = {}) ⇒ Object

OPERATIONS




39
40
41
42
43
44
# File 'lib/chargebee/models/export.rb', line 39

def self.retrieve(id, env=nil, headers={})
  jsonKeys = { 
  }
  options = {}
  Request.send('get', uri_path("exports",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
end

.revenue_recognition(params, env = nil, headers = {}) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/chargebee/models/export.rb', line 46

def self.revenue_recognition(params, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","revenue_recognition"), params, env, headers,nil, false, jsonKeys, options)
end

.subscriptions(params = {}, env = nil, headers = {}) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/chargebee/models/export.rb', line 100

def self.subscriptions(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","subscriptions"), params, env, headers,nil, false, jsonKeys, options)
end

.transactions(params = {}, env = nil, headers = {}) ⇒ Object



127
128
129
130
131
132
133
134
# File 'lib/chargebee/models/export.rb', line 127

def self.transactions(params={}, env=nil, headers={})
  jsonKeys = { 
  }
  options = {
      :isIdempotent => true
    }
  Request.send('post', uri_path("exports","transactions"), params, env, headers,nil, false, jsonKeys, options)
end

Instance Method Details

#wait_for_export_completion(env = nil, headers = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chargebee/models/export.rb', line 10

def wait_for_export_completion(env = nil, headers={})
  env = env || ChargeBee.default_env
  sleeptime = env.export_sleeptime

  export_final = (1..50).inject(self) do |export|
    break export if export.status != "in_process"
    sleep(sleeptime)
    self.class.retrieve(self.id, env, headers).export
  end

  # sync last fetched one with the current instance
  new_values = export_final.instance_variable_get("@values")
  self.instance_variable_set("@values", new_values)
  self.load(new_values)

  case export_final.status
  when "in_process"
    raise Error.new('Export is taking too long')
  when "failed"
    json_obj = Util.symbolize_keys(JSON.parse(self.error_json))
    raise OperationFailedError.new(json_obj[:http_code], json_obj)
  when "not_enabled", "_unknown"
    raise Error.new("Export status is in wrong state #{self.status}")
  end
end