Class: AboutYou::SDK::Model::InitiateOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/AboutYou/Model/initiate_order.rb

Overview

This class represents an initiate order model

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, user_token, app_token) ⇒ InitiateOrder

Returns a new instance of InitiateOrder.

Parameters:

  • string

    $url

  • string

    $user_token

  • string

    $app_token



21
22
23
24
25
26
27
# File 'lib/AboutYou/Model/initiate_order.rb', line 21

def initialize(url, user_token, app_token)
  self.url        = url
  self.user_token = user_token
  self.app_token  = app_token

  self
end

Instance Attribute Details

#app_tokenObject

Returns the value of attribute app_token.



12
13
14
# File 'lib/AboutYou/Model/initiate_order.rb', line 12

def app_token
  @app_token
end

#error_codeObject

Returns the value of attribute error_code.



13
14
15
# File 'lib/AboutYou/Model/initiate_order.rb', line 13

def error_code
  @error_code
end

#error_messageObject

Returns the value of attribute error_message.



14
15
16
# File 'lib/AboutYou/Model/initiate_order.rb', line 14

def error_message
  @error_message
end

#urlObject

Returns the value of attribute url.



10
11
12
# File 'lib/AboutYou/Model/initiate_order.rb', line 10

def url
  @url
end

#user_tokenObject

Returns the value of attribute user_token.



11
12
13
# File 'lib/AboutYou/Model/initiate_order.rb', line 11

def user_token
  @user_token
end

Class Method Details

.create_from_json(json_object) ⇒ Object

Returns static.

Parameters:

  • \stdClass

    $json

Returns:

  • static



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/AboutYou/Model/initiate_order.rb', line 34

def self.create_from_json(json_object)
  order = new(
      json_object['url'],
      json_object['user_token'],
      json_object['app_token']
  )

  order.parse_error_result(json_object)

  order
end

Instance Method Details

#parse_error_result(json_object) ⇒ Object



46
47
48
49
# File 'lib/AboutYou/Model/initiate_order.rb', line 46

def parse_error_result(json_object)
  self.error_code       = json_object.key?('error_code') ? json_object['error_code'] : 0
  self.error_message    = json_object.key?('error_message') ? json_object['error_message'] : nil
end