Class: Mailchimp::Ecomm

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Ecomm

Returns a new instance of Ecomm.



539
540
541
# File 'lib/mailchimp/api.rb', line 539

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



537
538
539
# File 'lib/mailchimp/api.rb', line 537

def master
  @master
end

Instance Method Details

#order_add(order) ⇒ Hash

Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins <a href=“connect.mailchimp.com/category/ecommerce” target=“_blank”>provided by us or by 3rd part system developers</a>.

Parameters:

  • order (Hash)

    information pertaining to the order that has completed. Use the following keys:

    • String

      id the Order Id

    • String

      campaign_id optional the Campaign Id to track this order against (see the “mc_cid” query string variable a campaign passes)

    • String

      email_id optional (kind of) the Email Id of the subscriber we should attach this order to (see the “mc_eid” query string variable a campaign passes) - required if campaign_id is passed, otherwise either this or <strong>email</strong> is required. If both are provided, email_id takes precedence

    • String

      email optional (kind of) the Email Address we should attach this order to - either this or <strong>email_id</strong> is required. If both are provided, email_id takes precedence

    • Double

      total The Order Total (ie, the full amount the customer ends up paying)

    • String

      order_date optional the date of the order - if this is not provided, we will default the date to now. Should be in the format of 2012-12-30

    • Double

      shipping optional the total paid for Shipping Fees

    • Double

      tax optional the total tax paid

    • String

      store_id a unique id for the store sending the order in (32 bytes max)

    • String

      store_name optional a “nice” name for the store - typically the base web address (ie, “store.mailchimp.com”). We will automatically update this if it changes (based on store_id)

    • Array

      items structs for each individual line item including:

      - [Int] line_num optional the line number of the item on the order. We will generate these if they are not passed
      - [Int] product_id the store's internal Id for the product. Lines that do no contain this will be skipped
      - [String] sku optional the store's internal SKU for the product. (max 30 bytes)
      - [String] product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
      - [Int] category_id (required) the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
      - [String] category_name (required) the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
      - [Double] qty optional the quantity of the item ordered - defaults to 1
      - [Double] cost optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
      

Returns:

  • (Hash)

    with a single entry:

    • Bool

      complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.



566
567
568
569
# File 'lib/mailchimp/api.rb', line 566

def order_add(order)
    _params = {:order => order}
    return @master.call 'ecomm/order-add', _params
end

#order_del(store_id, order_id) ⇒ Hash

Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins <a href=“/plugins/ecomm360.phtml”>that we provide</a> or by 3rd part system developers.

Parameters:

  • store_id (String)

    the store id the order belongs to

  • order_id (String)

    the order id (generated by the store) to delete

Returns:

  • (Hash)

    with a single entry:

    • Bool

      complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.



576
577
578
579
# File 'lib/mailchimp/api.rb', line 576

def order_del(store_id, order_id)
    _params = {:store_id => store_id, :order_id => order_id}
    return @master.call 'ecomm/order-del', _params
end

#orders(cid = nil, start = 0, limit = 100, since = nil) ⇒ Hash

Retrieve the Ecommerce Orders for an account

Parameters:

  • cid (String) (defaults to: nil)

    if set, limit the returned orders to a particular campaign

  • start (Int) (defaults to: 0)

    optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)

  • limit (Int) (defaults to: 100)

    optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500

  • since (String) (defaults to: nil)

    optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg “2013-12-30 20:30:00”

Returns:

  • (Hash)

    the total matching orders and the specific orders for the requested page

    • Int

      total the total matching orders

    • Array

      data structs for each order being returned

      - [String] store_id the store id generated by the plugin used to uniquely identify a store
      - [String] store_name the store name collected by the plugin - often the domain name
      - [String] order_id the internal order id the store tracked this order by
      - [String] email the email address that received this campaign and is associated with this order
      - [Double] order_total the order total
      - [Double] tax_total the total tax for the order (if collected)
      - [Double] ship_total the shipping total for the order (if collected)
      - [String] order_date the date the order was tracked - from the store if possible, otherwise the GMT time we received it
      - [Array] items structs for each line item on this order.:
          - [Int] line_num the line number
          - [Int] product_id the product id
          - [String] product_name the product name
          - [String] product_sku the sku for the product
          - [Int] product_category_id the category id for the product
          - [String] product_category_name the category name for the product
          - [Int] qty the quantity ordered
          - [Double] cost the cost of the item
      


606
607
608
609
# File 'lib/mailchimp/api.rb', line 606

def orders(cid=nil, start=0, limit=100, since=nil)
    _params = {:cid => cid, :start => start, :limit => limit, :since => since}
    return @master.call 'ecomm/orders', _params
end