Class: Aaww::Transaction
- Inherits:
-
Object
- Object
- Aaww::Transaction
- 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.
-
#ssl_link ⇒ Object
Returns the value of attribute ssl_link.
-
#token ⇒ Object
Returns the value of attribute token.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#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.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def email @email end |
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def file @file end |
#job_id ⇒ Object
Returns the value of attribute job_id.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def job_id @job_id end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def key @key end |
#link ⇒ Object
Returns the value of attribute link.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def link @link end |
#ssl_link ⇒ Object
Returns the value of attribute ssl_link.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def ssl_link @ssl_link end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def token @token end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/aaww/transaction.rb', line 5 def value @value end |
Instance Method Details
#create_token ⇒ Object
Creates a single unique token for this transaction Returns Token GET /api3/api_create_partner_token?api_key=#key
10 11 12 13 14 |
# File 'lib/aaww/transaction.rb', line 10 def create_token response = Aaww.get '/api3/api_create_partner_token', query: { api_key: key } self.token = response['data']['token'] response end |
#upload(file, email, value, job_id = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/aaww/transaction.rb', line 19 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
28 29 30 31 32 33 34 35 |
# File 'lib/aaww/transaction.rb', line 28 def upload! create_token if token.nil? response = Aaww.post '/api3/api_upload_partner_stl', query: upload_query self.link = response['data']['token_link'] self.ssl_link = response['data']['ssl_token_link'] response end |
#upload_query ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/aaww/transaction.rb', line 37 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 |