Class: Wegift::RemoteCode

Inherits:
Response show all
Defined in:
lib/wegift/models/remote_code.rb

Constant Summary

Constants inherited from Response

Wegift::Response::STATUS

Instance Attribute Summary collapse

Attributes inherited from Response

#error_code, #error_details, #error_string, #payload, #status

Instance Method Summary collapse

Methods inherited from Response

#is_successful?

Methods included from Initializable

#initialize

Instance Attribute Details

#amountObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def amount
  @amount
end

#barcode_formatObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def barcode_format
  @barcode_format
end

#barcode_stringObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def barcode_string
  @barcode_string
end

#codeObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def code
  @code
end

#expiry_dateObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def expiry_date
  @expiry_date
end

#pinObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def pin
  @pin
end

#typeObject

response/success



11
12
13
# File 'lib/wegift/models/remote_code.rb', line 11

def type
  @type
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/wegift/models/remote_code.rb', line 8

def url
  @url
end

Instance Method Details

#get(ctx) ⇒ Object



14
15
16
# File 'lib/wegift/models/remote_code.rb', line 14

def get(ctx)
  parse(Faraday.get("#{url}?format=json") { |r| r.headers['Accept'] = 'application/json' })
end

#parse(response) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/wegift/models/remote_code.rb', line 18

def parse(response)
  super

  if is_successful?
    self.class.new(@payload['e_code'])
  else
    self
  end
end