Class: ChargeBee::TimeMachine
- Defined in:
- lib/chargebee/models/time_machine.rb
Instance Attribute Summary collapse
-
#destination_time ⇒ Object
Returns the value of attribute destination_time.
-
#error_json ⇒ Object
Returns the value of attribute error_json.
-
#failure_code ⇒ Object
Returns the value of attribute failure_code.
-
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
-
#genesis_time ⇒ Object
Returns the value of attribute genesis_time.
-
#name ⇒ Object
Returns the value of attribute name.
-
#time_travel_status ⇒ Object
Returns the value of attribute time_travel_status.
Class Method Summary collapse
-
.retrieve(id, env = nil, headers = {}) ⇒ Object
OPERATIONS ———–.
- .start_afresh(id, params = {}, env = nil, headers = {}) ⇒ Object
- .travel_forward(id, params = {}, env = nil, headers = {}) ⇒ Object
Instance Method Summary collapse
Methods inherited from Model
construct, #init_dependant, #init_dependant_list, #initialize, #inspect, #load, #method_missing, #replace_white_space_with_underscore, #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
#destination_time ⇒ Object
Returns the value of attribute destination_time.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def destination_time @destination_time end |
#error_json ⇒ Object
Returns the value of attribute error_json.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def error_json @error_json end |
#failure_code ⇒ Object
Returns the value of attribute failure_code.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def failure_code @failure_code end |
#failure_reason ⇒ Object
Returns the value of attribute failure_reason.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def failure_reason @failure_reason end |
#genesis_time ⇒ Object
Returns the value of attribute genesis_time.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def genesis_time @genesis_time end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def name @name end |
#time_travel_status ⇒ Object
Returns the value of attribute time_travel_status.
4 5 6 |
# File 'lib/chargebee/models/time_machine.rb', line 4 def time_travel_status @time_travel_status end |
Class Method Details
.retrieve(id, env = nil, headers = {}) ⇒ Object
OPERATIONS
36 37 38 |
# File 'lib/chargebee/models/time_machine.rb', line 36 def self.retrieve(id, env=nil, headers={}) Request.send('get', uri_path("time_machines",id.to_s), {}, env, headers) end |
Instance Method Details
#wait_for_time_travel_completion(env = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chargebee/models/time_machine.rb', line 7 def wait_for_time_travel_completion(env = nil) env = env || ChargeBee.default_env sleeptime = env.time_machine_sleeptime tm = (1..30).inject(self) do |time_machine| break time_machine if time_machine.time_travel_status != "in_progress" sleep(sleeptime) self.class.retrieve(self.name, env).time_machine end # sync last fetched one with the current instance new_values = tm.instance_variable_get("@values") self.instance_variable_set("@values", new_values) self.load(new_values) case tm.time_travel_status when "in_progress" raise Error.new('The time travel is taking too much time') 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("Time travel status is in wrong state #{self.time_travel_status}") end end |