Module: Drip::Client::ShopperActivity
- Included in:
- Drip::Client
- Defined in:
- lib/drip/client/shopper_activity.rb
Instance Method Summary collapse
-
#create_cart_activity_event(data = {}) ⇒ Object
Public: Create a cart activity event.
-
#create_order_activity_event(data = {}) ⇒ Object
Public: Create an order activity event.
-
#create_order_activity_events(records = []) ⇒ Object
Public: Create a batch of order activity events.
-
#create_product_activity_event(data = {}) ⇒ Object
Public: Create a product activity event.
Instance Method Details
#create_cart_activity_event(data = {}) ⇒ Object
Public: Create a cart activity event.
options - Required. A Hash of additional cart options. Refer to the
Drip API docs for the required schema.
Returns a Drip::Response. See developer.drip.com/#cart-activity
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/drip/client/shopper_activity.rb', line 13 def create_cart_activity_event(data = {}) raise ArgumentError, 'email:, person_id:, or :visitor_uuid parameter required' if !data.key?(:email) && !data.key?(:person_id) && !data.key?(:visitor_uuid) %i[provider action cart_id cart_url].each do |key| raise ArgumentError, "#{key}: parameter required" unless data.key?(key) end data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at) make_json_request :post, "v3/#{account_id}/shopper_activity/cart", data end |
#create_order_activity_event(data = {}) ⇒ Object
Public: Create an order activity event.
options - Required. A Hash of additional order options. Refer to the
Drip API docs for the required schema.
Returns a Drip::Response. See developer.drip.com/#order-activity
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/drip/client/shopper_activity.rb', line 31 def create_order_activity_event(data = {}) raise ArgumentError, 'email: or person_id: parameter required' if !data.key?(:email) && !data.key?(:person_id) %i[provider action order_id].each do |key| raise ArgumentError, "#{key}: parameter required" unless data.key?(key) end data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at) make_json_request :post, "v3/#{account_id}/shopper_activity/order", data end |
#create_order_activity_events(records = []) ⇒ Object
Public: Create a batch of order activity events.
records - Required. An array of hashes containing orders attributes.
Refer to the Drip API docs for the required schema.
Returns a Drip::Response. See developer.drip.com/#create-or-update-a-batch-of-orders
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/drip/client/shopper_activity.rb', line 49 def create_order_activity_events(records = []) records.each_with_index do |record, i| raise ArgumentError, "email: or person_id: parameter required in record #{i}" if !record.key?(:email) && !record.key?(:person_id) %i[provider action order_id].each do |key| raise ArgumentError, "#{key}: parameter required in record #{i}" unless record.key?(key) end record[:occurred_at] = Time.now.iso8601 unless record.key?(:occurred_at) end make_json_request :post, "v3/#{account_id}/shopper_activity/order/batch", { orders: records } end |
#create_product_activity_event(data = {}) ⇒ Object
Public: Create a product activity event.
options - Required. A Hash of additional product options. Refer to the
Drip API docs for the required schema.
Returns a Drip::Response. See developer.drip.com/#product-activity
70 71 72 73 74 75 76 77 |
# File 'lib/drip/client/shopper_activity.rb', line 70 def create_product_activity_event(data = {}) %i[provider action product_id name price].each do |key| raise ArgumentError, "#{key}: parameter required" unless data.key?(key) end data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at) make_json_request :post, "v3/#{account_id}/shopper_activity/product", data end |