class YourMembership::Sa::Export

The Export object provides a convenient abstraction that encapsulates the export process

@attr_reader [String] export_id The unique ID assigned by the API when an export is initiated @attr_reader [Symbol] status The status of the current export request @attr_reader [String] export_uri The uri from which to download the requested report once the status is :complete

Attributes

export_id[R]
export_uri[R]
status[R]

Public Class Methods

all_invoiceItems(date, unicode) click to toggle source

Starts an export of all invoice items.

@see api.yourmembership.com/reference/2_00/Sa_Export_All_InvoiceItems.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 58
def self.all_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
  generic_export('Sa.Export.All.InvoiceItems', date, unicode)
end
career_openings(date, unicode) click to toggle source

Starts an export of career openings.

@see api.yourmembership.com/reference/2_00/Sa_Export_Career_Openings.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 69
def self.career_openings(date, unicode)
  generic_export('Sa.Export.Career.Openings', date, unicode)
end
donations_invoiceItems(date, unicode) click to toggle source

Starts an export of donation invoice items.

@see api.yourmembership.com/reference/2_00/Sa_Export_Donations_InvoiceItems.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 91
def self.donations_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
  generic_export('Sa.Export.Donations.InvoiceItems', date, unicode)
end
donations_transactions(date, unicode) click to toggle source

Starts an export of donation transactions.

@see api.yourmembership.com/reference/2_00/Sa_Export_Donations_Transactions.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 80
def self.donations_transactions(date, unicode)
  generic_export('Sa.Export.Donations.Transactions', date, unicode)
end
dues_invoiceItems(date, unicode) click to toggle source

Starts an export of dues invoice items.

@see api.yourmembership.com/reference/2_00/Sa_Export_Dues_InvoiceItems.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 113
def self.dues_invoiceItems(date, unicode)  # rubocop:disable Style/MethodName
  generic_export('Sa.Export.Dues.InvoiceItems', date, unicode)
end
dues_transactions(date, unicode) click to toggle source

Starts an export of dues transactions.

@see api.yourmembership.com/reference/2_00/Sa_Export_Dues_Transactions.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 102
def self.dues_transactions(date, unicode)
  generic_export('Sa.Export.Dues.Transactions', date, unicode)
end
event_registrations(event_id, unicode, options = {}) click to toggle source

Starts an export of registration records for an event

@see api.yourmembership.com/reference/2_00/Sa_Export_Event_Registrations.htm

@param [Integer] event_id Event ID of the event to view registrations. @param [Boolean] unicode Export format. @param [Hash] options @option options [String] :SessionIDs Comma Delimited List of Session IDs to filter the results. ex: “1234,9876” @option options [Integer] :ProductID Filter the results to only those that have purchased supplied Product ID. @option options [Integer] :Processed Filter the results by their Process Status.

Options: 0 = All, 1 = Open Records, 2 = Processed Records

@option options [String] :LastName Filter registrations by the supplied Last Name. @option options [Boolean] :AttendedEvent Filter registrations check in status. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 153
def self.event_registrations(event_id, unicode, options = {})  # rubocop:disable Style/MethodName
  options[:EventID] = event_id
  generic_export('Sa.Export.Event.Registrations', nil, unicode, options)
end
new(export_id) click to toggle source

Export Initializer - Use any of the public class methods to create objects of this type.

@note There is not yet a compelling reason to call Export.new() directly, however it can be done.

@param [String] export_id The ID of the export job for which to create the object.

# File lib/your_membership/sa_export.rb, line 16
def initialize(export_id)
  @export_id = export_id
  @status = nil
  @export_uri = nil
end
status(export_id) click to toggle source

Returns the status of an export by ExportID. This method should be called until a status of either FAILURE or COMPLETE is returned.

@see api.yourmembership.com/reference/2_00/Sa_Export_Status.htm

@param [String] export_id ID of the Export on which to check status. @return [Hash] Returns a hash with the status code for the current export as well as the URI of the exported

data if available
# File lib/your_membership/sa_export.rb, line 41
def self.status(export_id)
  options = {}
  options[:ExportID] = export_id

  response = post('/', :body => build_XML_request('Sa.Export.Status', nil, options))

  response_valid? response
  response['YourMembership_Response']['Sa.Export.Status']
end
store_invoiceItems(date, unicode) click to toggle source

Starts an export of store order invoice items.

@see api.yourmembership.com/reference/2_00/Sa_Export_Store_InvoiceItems.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 135
def self.store_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
  generic_export('Sa.Export.Store.InvoiceItems', date, unicode)
end
store_orders(date, unicode) click to toggle source

Starts an export of store orders.

@see api.yourmembership.com/reference/2_00/Sa_Export_Store_Orders.htm

@param [DateTime] date Date to export records from. @param [Boolean] unicode Export format. @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data

# File lib/your_membership/sa_export.rb, line 124
def self.store_orders(date, unicode)
  generic_export('Sa.Export.Store.Orders', date, unicode)
end

Private Class Methods

generic_export(api_method, date, unicode, options = {}) click to toggle source
# File lib/your_membership/sa_export.rb, line 160
def self.generic_export(api_method, date, unicode, options = {})
  options[:Unicode] = unicode
  options[:Date] = date

  response = post('/', :body => build_XML_request(api_method, nil, options))
  response_valid? response
  new(response['YourMembership_Response'][api_method]['ExportID'])
end

Private Instance Methods

convert_status(status) click to toggle source

Convert YourMembership API codes to readable symbols

@see api.yourmembership.com/reference/2_00/Sa_Export_Status.htm

@param [Integer] status The status code @return [Symbol] The status as a Symbol

# File lib/your_membership/sa_export.rb, line 179
def convert_status(status)
  case status
  when '-1'
    return :failure
  when '0'
    return :unknown
  when '1'
    return :working
  when '2'
    return :complete
  else
    return :error
  end
end
update_export_uri(status_response) click to toggle source
# File lib/your_membership/sa_export.rb, line 169
def update_export_uri(status_response)
  @export_uri = status_response['ExportURI']
end