Class: Jbr::Invoice
Constant Summary collapse
- FIND =
<<~GRAPHQL.freeze query($id: EncodedId!) { invoice(id: $id) { id total invoiceStatus issuedDate jobs { nodes { id completedAt } } } } GRAPHQL
Instance Attribute Summary collapse
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from Resource
Instance Method Summary collapse
-
#completed_at ⇒ Time
The job completed time.
- #find(id) ⇒ Object
-
#issued_at ⇒ Date
The invoice issued time.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Instance Attribute Details
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
10 11 12 |
# File 'lib/jbr/invoice.rb', line 10 def job_id @job_id end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
10 11 12 |
# File 'lib/jbr/invoice.rb', line 10 def total @total end |
Instance Method Details
#completed_at ⇒ Time
Returns the job completed time.
34 35 36 |
# File 'lib/jbr/invoice.rb', line 34 def completed_at Time.iso8601(@completed_at) if @completed_at end |
#find(id) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jbr/invoice.rb', line 12 def find(id) output = @oauth.query FIND, variables: { id: id } return unless invoice = output['invoice'] return if invoice['invoiceStatus'].eql? 'draft' @id = invoice['id'] @total = invoice['total'] @issued_at = invoice['issuedDate'] job = invoice.dig('jobs', 'nodes', 0) || {} @job_id = job['id'] @completed_at = job['completedAt'] self end |
#issued_at ⇒ Date
Returns the invoice issued time.
29 30 31 |
# File 'lib/jbr/invoice.rb', line 29 def issued_at Time.iso8601(@issued_at) if @issued_at end |