Class: Runa::RemoteCode
- Defined in:
- lib/runa/models/remote_code.rb
Constant Summary
Constants inherited from Response
Instance Attribute Summary collapse
-
#amount ⇒ Object
response/success.
-
#barcode_format ⇒ Object
response/success.
-
#barcode_string ⇒ Object
response/success.
-
#code ⇒ Object
response/success.
-
#expiry_date ⇒ Object
response/success.
-
#pin ⇒ Object
response/success.
-
#type ⇒ Object
response/success.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from Response
#error_code, #error_details, #error_string, #payload, #status
Instance Method Summary collapse
Methods inherited from Response
Methods included from Initializable
Instance Attribute Details
#amount ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def amount @amount end |
#barcode_format ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def @barcode_format end |
#barcode_string ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def @barcode_string end |
#code ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def code @code end |
#expiry_date ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def expiry_date @expiry_date end |
#pin ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def pin @pin end |
#type ⇒ Object
response/success
12 13 14 |
# File 'lib/runa/models/remote_code.rb', line 12 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/runa/models/remote_code.rb', line 9 def url @url end |
Instance Method Details
#get(ctx) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/runa/models/remote_code.rb', line 15 def get(ctx) conn = Faraday.new(url: url) do |c| c.adapter :net_http c.use FaradayMiddleware::FollowRedirects, limit: 5 end parse(conn.get("#{url}?format=json") { |r| r.headers['Accept'] = 'application/json' }) end |
#parse(response) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/runa/models/remote_code.rb', line 23 def parse(response) super if is_successful? self.class.new(@payload['e_code']) else self end end |