Class: Asdawqw::Authorization

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/authorization.rb

Overview

Authorization (Login) response

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(token = nil, message = nil, is_error = nil, error_message = nil, organization_id = nil, supplier_id = nil, party_id = nil, name = nil, currency = nil, code = nil) ⇒ Authorization

Returns a new instance of Authorization.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/asdawqw/models/authorization.rb', line 68

def initialize(token = nil,
               message = nil,
               is_error = nil,
               error_message = nil,
               organization_id = nil,
               supplier_id = nil,
               party_id = nil,
               name = nil,
               currency = nil,
               code = nil)
  @token = token
  @message = message
  @is_error = is_error
  @error_message = error_message
  @code = code
  @organization_id = organization_id
  @supplier_id = supplier_id
  @party_id = party_id
  @name = name
  @currency = currency
end

Instance Attribute Details

#codeString

Response code

Returns:



28
29
30
# File 'lib/asdawqw/models/authorization.rb', line 28

def code
  @code
end

#currencyString

Account currency

Returns:



50
51
52
# File 'lib/asdawqw/models/authorization.rb', line 50

def currency
  @currency
end

#error_messageList of String

Error Message(s) in Array format

Returns:



24
25
26
# File 'lib/asdawqw/models/authorization.rb', line 24

def error_message
  @error_message
end

#is_errorBoolean

Is request success or not

Returns:

  • (Boolean)


20
21
22
# File 'lib/asdawqw/models/authorization.rb', line 20

def is_error
  @is_error
end

#messageString

Message

Returns:



16
17
18
# File 'lib/asdawqw/models/authorization.rb', line 16

def message
  @message
end

#nameString

Account name

Returns:



46
47
48
# File 'lib/asdawqw/models/authorization.rb', line 46

def name
  @name
end

#organization_idInteger

Organization id - PMS ID

Returns:

  • (Integer)


32
33
34
# File 'lib/asdawqw/models/authorization.rb', line 32

def organization_id
  @organization_id
end

#party_idInteger

Deprecated field. It will be removed in version 3.3. Please use supplierId field instead

Returns:

  • (Integer)


42
43
44
# File 'lib/asdawqw/models/authorization.rb', line 42

def party_id
  @party_id
end

#supplier_idInteger

Supplier ID (Property Manager ID - or PMS ID - depend on account on which you are logged in)

Returns:

  • (Integer)


37
38
39
# File 'lib/asdawqw/models/authorization.rb', line 37

def supplier_id
  @supplier_id
end

#tokenString

Generated token for authorization. It must be used in every request to API as param jwt. Token is valid for 1h

Returns:



12
13
14
# File 'lib/asdawqw/models/authorization.rb', line 12

def token
  @token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/asdawqw/models/authorization.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  token = hash['token']
  message = hash['message']
  is_error = hash['is_error']
  error_message = hash['errorMessage']
  organization_id = hash['organizationId']
  supplier_id = hash['supplierId']
  party_id = hash['partyId']
  name = hash['name']
  currency = hash['currency']
  code = hash['code']

  # Create object from extracted values.
  Authorization.new(token,
                    message,
                    is_error,
                    error_message,
                    organization_id,
                    supplier_id,
                    party_id,
                    name,
                    currency,
                    code)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/asdawqw/models/authorization.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['token'] = 'token'
  @_hash['message'] = 'message'
  @_hash['is_error'] = 'is_error'
  @_hash['error_message'] = 'errorMessage'
  @_hash['code'] = 'code'
  @_hash['organization_id'] = 'organizationId'
  @_hash['supplier_id'] = 'supplierId'
  @_hash['party_id'] = 'partyId'
  @_hash['name'] = 'name'
  @_hash['currency'] = 'currency'
  @_hash
end