Class: Jbr::LineItem
Overview
One line of the work a job is made of: how many of a thing, what it is called, what it says, and what it comes to.
Direct Known Subclasses
Constant Summary collapse
- FIELDS =
What Jobber calls each field of a line. The ID reads through Resource#id, so an app can tell a line it has seen before from a new one.
%w[id quantity name description totalPrice]
- PAGE =
The most lines to read off one record. Bounded because Jobber prices a connection by the page it is asked for and prices an unbounded one at its own maximum, so the lines of a page of jobs were charged for as though every job had the largest job's worth of them.
20- SELECTION =
What to ask for wherever a record lists the lines it is made of.
"lineItems(first: #{PAGE}) { nodes { #{FIELDS.join ' '} } }"
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.from(nodes) ⇒ Array<LineItem>
One per line, in the order Jobber holds them.
Instance Method Summary collapse
-
#amount ⇒ Float?
What the line comes to — what Jobber calls
totalPrice. -
#description ⇒ String?
What the line says, beyond what it is called.
-
#name ⇒ String?
What the line is called.
-
#quantity ⇒ Integer, ...
How many of it the job is for.
-
#to_s ⇒ String
How many of what:
3 Bathroom Faucet Installation, and the name alone where Jobber holds no quantity for the line.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Jbr::Resource
Class Method Details
.from(nodes) ⇒ Array<LineItem>
Returns one per line, in the order Jobber holds them.
19 |
# File 'lib/jbr/line_item.rb', line 19 def self.from(nodes) = nodes.to_a.map { |node| new node: node } |
Instance Method Details
#amount ⇒ Float?
Returns what the line comes to — what Jobber calls totalPrice.
31 |
# File 'lib/jbr/line_item.rb', line 31 def amount = @node['totalPrice'] |
#description ⇒ String?
Returns what the line says, beyond what it is called.
28 |
# File 'lib/jbr/line_item.rb', line 28 def description = @node['description'] |
#name ⇒ String?
Returns what the line is called.
25 |
# File 'lib/jbr/line_item.rb', line 25 def name = @node['name'] |
#quantity ⇒ Integer, ...
Returns how many of it the job is for.
22 |
# File 'lib/jbr/line_item.rb', line 22 def quantity = whole @node['quantity'] |
#to_s ⇒ String
Returns how many of what: 3 Bathroom Faucet Installation, and the name alone
where Jobber holds no quantity for the line.
35 |
# File 'lib/jbr/line_item.rb', line 35 def to_s = [ quantity, name ].compact.join ' ' |