Class: Aaww::Transaction
- Inherits:
-
Object
- Object
- Aaww::Transaction
- Extended by:
- Forwardable
- Includes:
- ActiveModel::Model
- Defined in:
- lib/aaww/transaction.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#file ⇒ Object
Returns the value of attribute file.
-
#job_id ⇒ Object
Returns the value of attribute job_id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#link ⇒ Object
Returns the value of attribute link.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#ssl_link ⇒ Object
Returns the value of attribute ssl_link.
-
#status ⇒ Object
Returns the value of attribute status.
-
#token ⇒ Object
Returns the value of attribute token.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #check_print_status! ⇒ Object
-
#create_token ⇒ Object
Creates a single unique token for this transaction Returns Token GET /api3/api_create_partner_token?api_key=#key.
- #upload(file, email, value, job_id = nil) ⇒ Object
- #upload! ⇒ Object
- #upload_query ⇒ Object
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def email @email end |
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def file @file end |
#job_id ⇒ Object
Returns the value of attribute job_id.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def job_id @job_id end |
#key ⇒ Object
Returns the value of attribute key.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def key @key end |
#link ⇒ Object
Returns the value of attribute link.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def link @link end |
#progress ⇒ Object
Returns the value of attribute progress.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def progress @progress end |
#ssl_link ⇒ Object
Returns the value of attribute ssl_link.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def ssl_link @ssl_link end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def status @status end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def token @token end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/aaww/transaction.rb', line 6 def value @value end |
Instance Method Details
#check_print_status! ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/aaww/transaction.rb', line 56 def check_print_status! if token response = Aaww.get '/api3/api_get_partner_print_status', query: { api_key: key, token: token } self.status = Status.new response['status'] self.progress = Progress.new response['data'] response end end |
#create_token ⇒ Object
Creates a single unique token for this transaction Returns Token GET /api3/api_create_partner_token?api_key=#key
14 15 16 17 18 19 |
# File 'lib/aaww/transaction.rb', line 14 def create_token response = Aaww.get '/api3/api_create_partner_token', query: { api_key: key } self.status = Status.new response['status'] self.token = response['data']['token'] response end |
#upload(file, email, value, job_id = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/aaww/transaction.rb', line 24 def upload(file, email, value, job_id = nil) self.file = file self.email = email self.value = value self.job_id = job_id unless job_id.nil? upload! end |
#upload! ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/aaww/transaction.rb', line 33 def upload! create_token if token.nil? response = Aaww.post '/api3/api_upload_partner_stl', query: upload_query self.status = Status.new response['status'] self.link = response['data']['token_link'] self.ssl_link = response['data']['ssl_token_link'] response end |
#upload_query ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/aaww/transaction.rb', line 43 def upload_query { api_key: key, receiver_email: email, print_value: value, token: token, partner_job_id: job_id, stl_file: file }.reject { |_, value| value.nil? } end |