-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass opportunity_id to Integration::LineItem
So it doesnt have to query again for it
- Loading branch information
Showing
6 changed files
with
28 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
module Integration | ||
class LineItem < Base | ||
|
||
attr_reader :object | ||
attr_reader :order, :items | ||
|
||
def initialize(config, object) | ||
@object = object.with_indifferent_access | ||
super(config) | ||
end | ||
|
||
def upsert!(item) | ||
line_item_service.upsert!(item_params(item), look_up('id'), item.fetch('product_id')) | ||
end | ||
def initialize(config, order) | ||
@order = order | ||
@items = order[:line_items] | ||
|
||
def import! | ||
look_up('line_items').each { |li| upsert!(with_currency(li)) } | ||
end | ||
|
||
def with_currency(item) | ||
item.merge({ 'Currency' => look_up('currency') }) | ||
super(config) | ||
end | ||
|
||
def look_up(what) | ||
object[what] | ||
def upsert!(opportunity_id) | ||
items.each do |item| | ||
line_item_service.upsert!(item_params(item), opportunity_id, item.fetch('product_id')) | ||
end | ||
end | ||
|
||
def item_params(item) | ||
Integration::Builder::LineItem.new(item).build | ||
Integration::Builder::LineItem.new(item).build.merge 'Currency' => order['currency'] | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters