your_membership 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +5 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +10 -0
- data/README.md +12 -10
- data/lib/httparty/patch.rb +33 -33
- data/lib/your_membership/base.rb +197 -197
- data/lib/your_membership/commerce.rb +25 -25
- data/lib/your_membership/config.rb +41 -41
- data/lib/your_membership/convert.rb +24 -24
- data/lib/your_membership/error.rb +21 -21
- data/lib/your_membership/events.rb +60 -60
- data/lib/your_membership/feeds.rb +37 -37
- data/lib/your_membership/member.rb +399 -397
- data/lib/your_membership/members.rb +124 -124
- data/lib/your_membership/people.rb +38 -38
- data/lib/your_membership/profile.rb +92 -85
- data/lib/your_membership/sa.rb +6 -6
- data/lib/your_membership/sa_auth.rb +34 -34
- data/lib/your_membership/sa_certifications.rb +22 -22
- data/lib/your_membership/sa_commerce.rb +22 -22
- data/lib/your_membership/sa_events.rb +66 -66
- data/lib/your_membership/sa_export.rb +195 -195
- data/lib/your_membership/sa_groups.rb +30 -30
- data/lib/your_membership/sa_member.rb +49 -49
- data/lib/your_membership/sa_members.rb +180 -179
- data/lib/your_membership/sa_nonmembers.rb +41 -41
- data/lib/your_membership/sa_people.rb +92 -92
- data/lib/your_membership/session.rb +148 -152
- data/lib/your_membership/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_multiple.yml +51 -0
- data/spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_none.yml +51 -0
- data/spec/fixtures/vcr_cassettes/sa_members_all_getids_timestamp_single.yml +51 -0
- data/spec/lib/{profile_spec.rb → your_membership/profile_spec.rb} +232 -197
- data/spec/lib/your_membership/sa_members_spec.rb +38 -0
- data/spec/spec_helper.rb +101 -78
- data/your_membership.gemspec +4 -0
- metadata +85 -19
data/lib/your_membership/sa.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
module YourMembership
|
2
|
-
# The SA Namespace encapsulates System Administrator functions of the API. These functions are a special case that
|
3
|
-
# do not usually require a session or user scope.
|
4
|
-
module Sa
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
# The SA Namespace encapsulates System Administrator functions of the API. These functions are a special case that
|
3
|
+
# do not usually require a session or user scope.
|
4
|
+
module Sa
|
5
|
+
end
|
6
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
module YourMembership
|
2
|
-
module Sa
|
3
|
-
# YourMembership System Administrator Member Authentication
|
4
|
-
class Auth < YourMembership::Base
|
5
|
-
# Authenticates a member's username and password and binds them to the current API session.
|
6
|
-
#
|
7
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Auth_Authenticate.htm
|
8
|
-
#
|
9
|
-
# @param [YourMembership::Session] session
|
10
|
-
# @param [String] user_name The Username of the user the session should be bound to.
|
11
|
-
# @param [String] password The Password (Optional) pf the specified user.
|
12
|
-
# @param [String] password_hash The Password Hash for the specified user which allows the system to perform
|
13
|
-
# actions on behalf of a user as if they were signed in without knowing the user's cleartext password.
|
14
|
-
# @return [YourMembership::Member] Returns a Member object for the authenticated session.
|
15
|
-
def self.authenticate(session, user_name, password = nil, password_hash = nil)
|
16
|
-
options = {}
|
17
|
-
options[:Username] = user_name
|
18
|
-
options[:Password] = password if password
|
19
|
-
options[:PasswordHash] = password_hash if password_hash
|
20
|
-
|
21
|
-
response = post('/', :body => build_XML_request('Sa.Auth.Authenticate', session, options))
|
22
|
-
|
23
|
-
response_valid? response
|
24
|
-
if response['YourMembership_Response']['Sa.Auth.Authenticate']
|
25
|
-
session.get_authenticated_user
|
26
|
-
else
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
|
30
|
-
YourMembership::Member.create_from_session(session)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Member Authentication
|
4
|
+
class Auth < YourMembership::Base
|
5
|
+
# Authenticates a member's username and password and binds them to the current API session.
|
6
|
+
#
|
7
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Auth_Authenticate.htm
|
8
|
+
#
|
9
|
+
# @param [YourMembership::Session] session
|
10
|
+
# @param [String] user_name The Username of the user the session should be bound to.
|
11
|
+
# @param [String] password The Password (Optional) pf the specified user.
|
12
|
+
# @param [String] password_hash The Password Hash for the specified user which allows the system to perform
|
13
|
+
# actions on behalf of a user as if they were signed in without knowing the user's cleartext password.
|
14
|
+
# @return [YourMembership::Member] Returns a Member object for the authenticated session.
|
15
|
+
def self.authenticate(session, user_name, password = nil, password_hash = nil)
|
16
|
+
options = {}
|
17
|
+
options[:Username] = user_name
|
18
|
+
options[:Password] = password if password
|
19
|
+
options[:PasswordHash] = password_hash if password_hash
|
20
|
+
|
21
|
+
response = post('/', :body => build_XML_request('Sa.Auth.Authenticate', session, options))
|
22
|
+
|
23
|
+
response_valid? response
|
24
|
+
if response['YourMembership_Response']['Sa.Auth.Authenticate']
|
25
|
+
session.get_authenticated_user
|
26
|
+
else
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
|
30
|
+
YourMembership::Member.create_from_session(session)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
module YourMembership
|
2
|
-
module Sa
|
3
|
-
# YourMembership System Administrator Certifications Namespace
|
4
|
-
class Certifications < YourMembership::Base
|
5
|
-
# Return a list of all certification records for the community.
|
6
|
-
#
|
7
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Certifications_All_Get.htm
|
8
|
-
#
|
9
|
-
# @param [Boolean] is_active Include active certification records in the returned result. Default: True
|
10
|
-
# @return [Array] Returns an Array of Hashes representing Certification Records
|
11
|
-
def self.all_get(is_active = true)
|
12
|
-
options = {}
|
13
|
-
options[:IsActive] = is_active
|
14
|
-
|
15
|
-
response = post('/', :body => build_XML_request('Sa.Certifications.All.Get', nil, options))
|
16
|
-
|
17
|
-
response_valid? response
|
18
|
-
response_to_array_of_hashes response['YourMembership_Response']['Sa.Certifications.All.Get'], ['Certification']
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Certifications Namespace
|
4
|
+
class Certifications < YourMembership::Base
|
5
|
+
# Return a list of all certification records for the community.
|
6
|
+
#
|
7
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Certifications_All_Get.htm
|
8
|
+
#
|
9
|
+
# @param [Boolean] is_active Include active certification records in the returned result. Default: True
|
10
|
+
# @return [Array] Returns an Array of Hashes representing Certification Records
|
11
|
+
def self.all_get(is_active = true)
|
12
|
+
options = {}
|
13
|
+
options[:IsActive] = is_active
|
14
|
+
|
15
|
+
response = post('/', :body => build_XML_request('Sa.Certifications.All.Get', nil, options))
|
16
|
+
|
17
|
+
response_valid? response
|
18
|
+
response_to_array_of_hashes response['YourMembership_Response']['Sa.Certifications.All.Get'], ['Certification']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
module YourMembership
|
2
|
-
module Sa
|
3
|
-
# YourMembership System Administrator Commerce Namespace
|
4
|
-
class Commerce < YourMembership::Base
|
5
|
-
# Returns the order details, including line items and products ordered, of a store order.
|
6
|
-
#
|
7
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Commerce_Store_Order_Get.htm
|
8
|
-
#
|
9
|
-
# @param [String] invoice_id The Invoice ID of the store order to be returned.
|
10
|
-
# @return [Hash] Returns a Hash representing a store order
|
11
|
-
def self.store_order_get(invoice_id)
|
12
|
-
options = {}
|
13
|
-
options[:InvoiceID] = invoice_id
|
14
|
-
|
15
|
-
response = post('/', :body => build_XML_request('Sa.Commerce.Store.Order.Get', nil, options))
|
16
|
-
|
17
|
-
response_valid? response
|
18
|
-
response['YourMembership_Response']['Sa.Commerce.Store.Order.Get']
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Commerce Namespace
|
4
|
+
class Commerce < YourMembership::Base
|
5
|
+
# Returns the order details, including line items and products ordered, of a store order.
|
6
|
+
#
|
7
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Commerce_Store_Order_Get.htm
|
8
|
+
#
|
9
|
+
# @param [String] invoice_id The Invoice ID of the store order to be returned.
|
10
|
+
# @return [Hash] Returns a Hash representing a store order
|
11
|
+
def self.store_order_get(invoice_id)
|
12
|
+
options = {}
|
13
|
+
options[:InvoiceID] = invoice_id
|
14
|
+
|
15
|
+
response = post('/', :body => build_XML_request('Sa.Commerce.Store.Order.Get', nil, options))
|
16
|
+
|
17
|
+
response_valid? response
|
18
|
+
response['YourMembership_Response']['Sa.Commerce.Store.Order.Get']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,66 +1,66 @@
|
|
1
|
-
module YourMembership
|
2
|
-
module Sa
|
3
|
-
# YourMembership System Administrator Events Namespace
|
4
|
-
class Events < YourMembership::Base
|
5
|
-
# Returns a list of Events for the community optionally filtered by date or event name.
|
6
|
-
#
|
7
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_All_GetIDs.htm
|
8
|
-
#
|
9
|
-
# @param [Hash] options
|
10
|
-
# @option options [DateTime] :StartDate Starting date to filter the Event Start Date.
|
11
|
-
# @option options [DateTime] :EndDate Ending date to filter the Event Start Date.
|
12
|
-
# @option options [String] :Name Filter the returned events by Event Name.
|
13
|
-
# @return [Array] Returns an Array of Event IDs
|
14
|
-
def self.all_getIDs(options = {}) # rubocop:disable Style/MethodName
|
15
|
-
response = post('/', :body => build_XML_request('Sa.Events.All.GetIDs', nil, options))
|
16
|
-
|
17
|
-
response_valid? response
|
18
|
-
if response['YourMembership_Response']['Sa.Events.All.GetIDs']
|
19
|
-
response['YourMembership_Response']['Sa.Events.All.GetIDs']['EventID']
|
20
|
-
else
|
21
|
-
return[]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns Event Registration details for the provided Event and Event Registration ID. If the Event Registration
|
26
|
-
# contains a related Custom Form, the form data will be included in the <DataSet> element as it is stored in our
|
27
|
-
# database.
|
28
|
-
#
|
29
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_Event_Registration_Get.htm
|
30
|
-
#
|
31
|
-
# @param [Integer] event_id The ID number for the Event from which you wish to retrieve the Event Registration.
|
32
|
-
# @param [Hash] options Either RegistrationID or Badge Number are required.
|
33
|
-
# @option options [String] :RegistrationID RegistrationID of the Registration data to return.
|
34
|
-
# @option options [Integer] :BadgeNumber The Badge Number / Registration Number for an Event Registration record.
|
35
|
-
# @return [Hash] Returns a Hash representing an event registration
|
36
|
-
def self.event_registration_get(event_id, options = {})
|
37
|
-
options[:EventID] = event_id
|
38
|
-
|
39
|
-
response = post('/', :body => build_XML_request('Sa.Events.Event.Registration.Get', nil, options))
|
40
|
-
|
41
|
-
response_valid? response
|
42
|
-
response['YourMembership_Response']['Sa.Events.Event.Registration.Get']
|
43
|
-
end
|
44
|
-
|
45
|
-
# Returns a list of Registration IDs for the specified Event ID.
|
46
|
-
#
|
47
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_Event_Registrations_GetIDs.htm
|
48
|
-
#
|
49
|
-
# @param [Integer] event_id The ID number for the Event from which you wish to retrieve the Event Registration.
|
50
|
-
# @return [Array] Returns an Array of registration IDs for a specific event.
|
51
|
-
def self.event_registrations_getIDs(event_id) # rubocop:disable Style/MethodName
|
52
|
-
options = {}
|
53
|
-
options[:EventID] = event_id
|
54
|
-
|
55
|
-
response = post('/', :body => build_XML_request('Sa.Events.Event.Registrations.GetIDs', nil, options))
|
56
|
-
|
57
|
-
response_valid? response
|
58
|
-
if response['YourMembership_Response']['Sa.Events.Event.Registrations.GetIDs']
|
59
|
-
response['YourMembership_Response']['Sa.Events.Event.Registrations.GetIDs']['RegistrationID']
|
60
|
-
else
|
61
|
-
return []
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# YourMembership System Administrator Events Namespace
|
4
|
+
class Events < YourMembership::Base
|
5
|
+
# Returns a list of Events for the community optionally filtered by date or event name.
|
6
|
+
#
|
7
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_All_GetIDs.htm
|
8
|
+
#
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [DateTime] :StartDate Starting date to filter the Event Start Date.
|
11
|
+
# @option options [DateTime] :EndDate Ending date to filter the Event Start Date.
|
12
|
+
# @option options [String] :Name Filter the returned events by Event Name.
|
13
|
+
# @return [Array] Returns an Array of Event IDs
|
14
|
+
def self.all_getIDs(options = {}) # rubocop:disable Style/MethodName
|
15
|
+
response = post('/', :body => build_XML_request('Sa.Events.All.GetIDs', nil, options))
|
16
|
+
|
17
|
+
response_valid? response
|
18
|
+
if response['YourMembership_Response']['Sa.Events.All.GetIDs']
|
19
|
+
response['YourMembership_Response']['Sa.Events.All.GetIDs']['EventID']
|
20
|
+
else
|
21
|
+
return[]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns Event Registration details for the provided Event and Event Registration ID. If the Event Registration
|
26
|
+
# contains a related Custom Form, the form data will be included in the <DataSet> element as it is stored in our
|
27
|
+
# database.
|
28
|
+
#
|
29
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_Event_Registration_Get.htm
|
30
|
+
#
|
31
|
+
# @param [Integer] event_id The ID number for the Event from which you wish to retrieve the Event Registration.
|
32
|
+
# @param [Hash] options Either RegistrationID or Badge Number are required.
|
33
|
+
# @option options [String] :RegistrationID RegistrationID of the Registration data to return.
|
34
|
+
# @option options [Integer] :BadgeNumber The Badge Number / Registration Number for an Event Registration record.
|
35
|
+
# @return [Hash] Returns a Hash representing an event registration
|
36
|
+
def self.event_registration_get(event_id, options = {})
|
37
|
+
options[:EventID] = event_id
|
38
|
+
|
39
|
+
response = post('/', :body => build_XML_request('Sa.Events.Event.Registration.Get', nil, options))
|
40
|
+
|
41
|
+
response_valid? response
|
42
|
+
response['YourMembership_Response']['Sa.Events.Event.Registration.Get']
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns a list of Registration IDs for the specified Event ID.
|
46
|
+
#
|
47
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Events_Event_Registrations_GetIDs.htm
|
48
|
+
#
|
49
|
+
# @param [Integer] event_id The ID number for the Event from which you wish to retrieve the Event Registration.
|
50
|
+
# @return [Array] Returns an Array of registration IDs for a specific event.
|
51
|
+
def self.event_registrations_getIDs(event_id) # rubocop:disable Style/MethodName
|
52
|
+
options = {}
|
53
|
+
options[:EventID] = event_id
|
54
|
+
|
55
|
+
response = post('/', :body => build_XML_request('Sa.Events.Event.Registrations.GetIDs', nil, options))
|
56
|
+
|
57
|
+
response_valid? response
|
58
|
+
if response['YourMembership_Response']['Sa.Events.Event.Registrations.GetIDs']
|
59
|
+
response['YourMembership_Response']['Sa.Events.Event.Registrations.GetIDs']['RegistrationID']
|
60
|
+
else
|
61
|
+
return []
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,195 +1,195 @@
|
|
1
|
-
module YourMembership
|
2
|
-
module Sa
|
3
|
-
# The Export object provides a convenient abstraction that encapsulates the export process
|
4
|
-
#
|
5
|
-
# @attr_reader [String] export_id The unique ID assigned by the API when an export is initiated
|
6
|
-
# @attr_reader [Symbol] status The status of the current export request
|
7
|
-
# @attr_reader [String] export_uri The uri from which to download the requested report once the status is :complete
|
8
|
-
class Export < YourMembership::Base
|
9
|
-
attr_reader :export_id, :status, :export_uri
|
10
|
-
|
11
|
-
# Export Initializer - Use any of the public class methods to create objects of this type.
|
12
|
-
#
|
13
|
-
# @note There is not yet a compelling reason to call Export.new() directly, however it can be done.
|
14
|
-
#
|
15
|
-
# @param [String] export_id The ID of the export job for which to create the object.
|
16
|
-
def initialize(export_id)
|
17
|
-
@export_id = export_id
|
18
|
-
@status = nil
|
19
|
-
@export_uri = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
# Instance implementation of the Sa::Export.status method that also sets the export_uri if the status is :complete
|
23
|
-
# @return [Symbol] Returns the symbol for the current status state.
|
24
|
-
def status
|
25
|
-
unless @status == :complete || @status == :error || @status == :failure
|
26
|
-
status_response = self.class.status(@export_id)
|
27
|
-
@status = convert_status(status_response['Status'])
|
28
|
-
update_export_uri(status_response) if @status == :complete
|
29
|
-
end
|
30
|
-
@status
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the status of an export by ExportID. This method should be called until a status of either
|
34
|
-
# FAILURE or COMPLETE is returned.
|
35
|
-
#
|
36
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Status.htm
|
37
|
-
#
|
38
|
-
# @param [String] export_id ID of the Export on which to check status.
|
39
|
-
# @return [Hash] Returns a hash with the status code for the current export as well as the URI of the exported
|
40
|
-
# data if available
|
41
|
-
def self.status(export_id)
|
42
|
-
options = {}
|
43
|
-
options[:ExportID] = export_id
|
44
|
-
|
45
|
-
response = post('/', :body => build_XML_request('Sa.Export.Status', nil, options))
|
46
|
-
|
47
|
-
response_valid? response
|
48
|
-
response['YourMembership_Response']['Sa.Export.Status']
|
49
|
-
end
|
50
|
-
|
51
|
-
# Starts an export of all invoice items.
|
52
|
-
#
|
53
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_All_InvoiceItems.htm
|
54
|
-
#
|
55
|
-
# @param [DateTime] date Date to export records from.
|
56
|
-
# @param [Boolean] unicode Export format.
|
57
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
58
|
-
def self.all_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
59
|
-
generic_export('Sa.Export.All.InvoiceItems', date, unicode)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Starts an export of career openings.
|
63
|
-
#
|
64
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Career_Openings.htm
|
65
|
-
#
|
66
|
-
# @param [DateTime] date Date to export records from.
|
67
|
-
# @param [Boolean] unicode Export format.
|
68
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
69
|
-
def self.career_openings(date, unicode)
|
70
|
-
generic_export('Sa.Export.Career.Openings', date, unicode)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Starts an export of donation transactions.
|
74
|
-
#
|
75
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Donations_Transactions.htm
|
76
|
-
#
|
77
|
-
# @param [DateTime] date Date to export records from.
|
78
|
-
# @param [Boolean] unicode Export format.
|
79
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
80
|
-
def self.donations_transactions(date, unicode)
|
81
|
-
generic_export('Sa.Export.Donations.Transactions', date, unicode)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Starts an export of donation invoice items.
|
85
|
-
#
|
86
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Donations_InvoiceItems.htm
|
87
|
-
#
|
88
|
-
# @param [DateTime] date Date to export records from.
|
89
|
-
# @param [Boolean] unicode Export format.
|
90
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
91
|
-
def self.donations_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
92
|
-
generic_export('Sa.Export.Donations.InvoiceItems', date, unicode)
|
93
|
-
end
|
94
|
-
|
95
|
-
# Starts an export of dues transactions.
|
96
|
-
#
|
97
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Dues_Transactions.htm
|
98
|
-
#
|
99
|
-
# @param [DateTime] date Date to export records from.
|
100
|
-
# @param [Boolean] unicode Export format.
|
101
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
102
|
-
def self.dues_transactions(date, unicode)
|
103
|
-
generic_export('Sa.Export.Dues.Transactions', date, unicode)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Starts an export of dues invoice items.
|
107
|
-
#
|
108
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Dues_InvoiceItems.htm
|
109
|
-
#
|
110
|
-
# @param [DateTime] date Date to export records from.
|
111
|
-
# @param [Boolean] unicode Export format.
|
112
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
113
|
-
def self.dues_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
114
|
-
generic_export('Sa.Export.Dues.InvoiceItems', date, unicode)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Starts an export of store orders.
|
118
|
-
#
|
119
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Store_Orders.htm
|
120
|
-
#
|
121
|
-
# @param [DateTime] date Date to export records from.
|
122
|
-
# @param [Boolean] unicode Export format.
|
123
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
124
|
-
def self.store_orders(date, unicode)
|
125
|
-
generic_export('Sa.Export.Store.Orders', date, unicode)
|
126
|
-
end
|
127
|
-
|
128
|
-
# Starts an export of store order invoice items.
|
129
|
-
#
|
130
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Store_InvoiceItems.htm
|
131
|
-
#
|
132
|
-
# @param [DateTime] date Date to export records from.
|
133
|
-
# @param [Boolean] unicode Export format.
|
134
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
135
|
-
def self.store_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
136
|
-
generic_export('Sa.Export.Store.InvoiceItems', date, unicode)
|
137
|
-
end
|
138
|
-
|
139
|
-
# Starts an export of registration records for an event
|
140
|
-
#
|
141
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Event_Registrations.htm
|
142
|
-
#
|
143
|
-
# @param [Integer] event_id Event ID of the event to view registrations.
|
144
|
-
# @param [Boolean] unicode Export format.
|
145
|
-
# @param [Hash] options
|
146
|
-
# @option options [String] :SessionIDs Comma Delimited List of Session IDs to filter the results. ex: "1234,9876"
|
147
|
-
# @option options [Integer] :ProductID Filter the results to only those that have purchased supplied Product ID.
|
148
|
-
# @option options [Integer] :Processed Filter the results by their Process Status.
|
149
|
-
# Options: 0 = All, 1 = Open Records, 2 = Processed Records
|
150
|
-
# @option options [String] :LastName Filter registrations by the supplied Last Name.
|
151
|
-
# @option options [Boolean] :AttendedEvent Filter registrations check in status.
|
152
|
-
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
153
|
-
def self.event_registrations(event_id, unicode, options = {}) # rubocop:disable Style/MethodName
|
154
|
-
options[:EventID] = event_id
|
155
|
-
generic_export('Sa.Export.Event.Registrations', nil, unicode, options)
|
156
|
-
end
|
157
|
-
|
158
|
-
private
|
159
|
-
|
160
|
-
def self.generic_export(api_method, date, unicode, options = {})
|
161
|
-
options[:Unicode] = unicode
|
162
|
-
options[:Date] = date
|
163
|
-
|
164
|
-
response = post('/', :body => build_XML_request(api_method, nil, options))
|
165
|
-
response_valid? response
|
166
|
-
new(response['YourMembership_Response'][api_method]['ExportID'])
|
167
|
-
end
|
168
|
-
|
169
|
-
def update_export_uri(status_response)
|
170
|
-
@export_uri = status_response['ExportURI']
|
171
|
-
end
|
172
|
-
|
173
|
-
# Convert YourMembership API codes to readable symbols
|
174
|
-
#
|
175
|
-
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Status.htm
|
176
|
-
#
|
177
|
-
# @param [Integer] status The status code
|
178
|
-
# @return [Symbol] The status as a Symbol
|
179
|
-
def convert_status(status)
|
180
|
-
case status
|
181
|
-
when '-1'
|
182
|
-
return :failure
|
183
|
-
when '0'
|
184
|
-
return :unknown
|
185
|
-
when '1'
|
186
|
-
return :working
|
187
|
-
when '2'
|
188
|
-
return :complete
|
189
|
-
else
|
190
|
-
return :error
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
1
|
+
module YourMembership
|
2
|
+
module Sa
|
3
|
+
# The Export object provides a convenient abstraction that encapsulates the export process
|
4
|
+
#
|
5
|
+
# @attr_reader [String] export_id The unique ID assigned by the API when an export is initiated
|
6
|
+
# @attr_reader [Symbol] status The status of the current export request
|
7
|
+
# @attr_reader [String] export_uri The uri from which to download the requested report once the status is :complete
|
8
|
+
class Export < YourMembership::Base
|
9
|
+
attr_reader :export_id, :status, :export_uri
|
10
|
+
|
11
|
+
# Export Initializer - Use any of the public class methods to create objects of this type.
|
12
|
+
#
|
13
|
+
# @note There is not yet a compelling reason to call Export.new() directly, however it can be done.
|
14
|
+
#
|
15
|
+
# @param [String] export_id The ID of the export job for which to create the object.
|
16
|
+
def initialize(export_id)
|
17
|
+
@export_id = export_id
|
18
|
+
@status = nil
|
19
|
+
@export_uri = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# Instance implementation of the Sa::Export.status method that also sets the export_uri if the status is :complete
|
23
|
+
# @return [Symbol] Returns the symbol for the current status state.
|
24
|
+
def status
|
25
|
+
unless @status == :complete || @status == :error || @status == :failure
|
26
|
+
status_response = self.class.status(@export_id)
|
27
|
+
@status = convert_status(status_response['Status'])
|
28
|
+
update_export_uri(status_response) if @status == :complete
|
29
|
+
end
|
30
|
+
@status
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the status of an export by ExportID. This method should be called until a status of either
|
34
|
+
# FAILURE or COMPLETE is returned.
|
35
|
+
#
|
36
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Status.htm
|
37
|
+
#
|
38
|
+
# @param [String] export_id ID of the Export on which to check status.
|
39
|
+
# @return [Hash] Returns a hash with the status code for the current export as well as the URI of the exported
|
40
|
+
# data if available
|
41
|
+
def self.status(export_id)
|
42
|
+
options = {}
|
43
|
+
options[:ExportID] = export_id
|
44
|
+
|
45
|
+
response = post('/', :body => build_XML_request('Sa.Export.Status', nil, options))
|
46
|
+
|
47
|
+
response_valid? response
|
48
|
+
response['YourMembership_Response']['Sa.Export.Status']
|
49
|
+
end
|
50
|
+
|
51
|
+
# Starts an export of all invoice items.
|
52
|
+
#
|
53
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_All_InvoiceItems.htm
|
54
|
+
#
|
55
|
+
# @param [DateTime] date Date to export records from.
|
56
|
+
# @param [Boolean] unicode Export format.
|
57
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
58
|
+
def self.all_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
59
|
+
generic_export('Sa.Export.All.InvoiceItems', date, unicode)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Starts an export of career openings.
|
63
|
+
#
|
64
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Career_Openings.htm
|
65
|
+
#
|
66
|
+
# @param [DateTime] date Date to export records from.
|
67
|
+
# @param [Boolean] unicode Export format.
|
68
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
69
|
+
def self.career_openings(date, unicode)
|
70
|
+
generic_export('Sa.Export.Career.Openings', date, unicode)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Starts an export of donation transactions.
|
74
|
+
#
|
75
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Donations_Transactions.htm
|
76
|
+
#
|
77
|
+
# @param [DateTime] date Date to export records from.
|
78
|
+
# @param [Boolean] unicode Export format.
|
79
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
80
|
+
def self.donations_transactions(date, unicode)
|
81
|
+
generic_export('Sa.Export.Donations.Transactions', date, unicode)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Starts an export of donation invoice items.
|
85
|
+
#
|
86
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Donations_InvoiceItems.htm
|
87
|
+
#
|
88
|
+
# @param [DateTime] date Date to export records from.
|
89
|
+
# @param [Boolean] unicode Export format.
|
90
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
91
|
+
def self.donations_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
92
|
+
generic_export('Sa.Export.Donations.InvoiceItems', date, unicode)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Starts an export of dues transactions.
|
96
|
+
#
|
97
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Dues_Transactions.htm
|
98
|
+
#
|
99
|
+
# @param [DateTime] date Date to export records from.
|
100
|
+
# @param [Boolean] unicode Export format.
|
101
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
102
|
+
def self.dues_transactions(date, unicode)
|
103
|
+
generic_export('Sa.Export.Dues.Transactions', date, unicode)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Starts an export of dues invoice items.
|
107
|
+
#
|
108
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Dues_InvoiceItems.htm
|
109
|
+
#
|
110
|
+
# @param [DateTime] date Date to export records from.
|
111
|
+
# @param [Boolean] unicode Export format.
|
112
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
113
|
+
def self.dues_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
114
|
+
generic_export('Sa.Export.Dues.InvoiceItems', date, unicode)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Starts an export of store orders.
|
118
|
+
#
|
119
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Store_Orders.htm
|
120
|
+
#
|
121
|
+
# @param [DateTime] date Date to export records from.
|
122
|
+
# @param [Boolean] unicode Export format.
|
123
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
124
|
+
def self.store_orders(date, unicode)
|
125
|
+
generic_export('Sa.Export.Store.Orders', date, unicode)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Starts an export of store order invoice items.
|
129
|
+
#
|
130
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Store_InvoiceItems.htm
|
131
|
+
#
|
132
|
+
# @param [DateTime] date Date to export records from.
|
133
|
+
# @param [Boolean] unicode Export format.
|
134
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
135
|
+
def self.store_invoiceItems(date, unicode) # rubocop:disable Style/MethodName
|
136
|
+
generic_export('Sa.Export.Store.InvoiceItems', date, unicode)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Starts an export of registration records for an event
|
140
|
+
#
|
141
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Event_Registrations.htm
|
142
|
+
#
|
143
|
+
# @param [Integer] event_id Event ID of the event to view registrations.
|
144
|
+
# @param [Boolean] unicode Export format.
|
145
|
+
# @param [Hash] options
|
146
|
+
# @option options [String] :SessionIDs Comma Delimited List of Session IDs to filter the results. ex: "1234,9876"
|
147
|
+
# @option options [Integer] :ProductID Filter the results to only those that have purchased supplied Product ID.
|
148
|
+
# @option options [Integer] :Processed Filter the results by their Process Status.
|
149
|
+
# Options: 0 = All, 1 = Open Records, 2 = Processed Records
|
150
|
+
# @option options [String] :LastName Filter registrations by the supplied Last Name.
|
151
|
+
# @option options [Boolean] :AttendedEvent Filter registrations check in status.
|
152
|
+
# @return [YourMembership::Sa::Export] Returns an Export object that can be queried for status and the export data
|
153
|
+
def self.event_registrations(event_id, unicode, options = {}) # rubocop:disable Style/MethodName
|
154
|
+
options[:EventID] = event_id
|
155
|
+
generic_export('Sa.Export.Event.Registrations', nil, unicode, options)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def self.generic_export(api_method, date, unicode, options = {})
|
161
|
+
options[:Unicode] = unicode
|
162
|
+
options[:Date] = date
|
163
|
+
|
164
|
+
response = post('/', :body => build_XML_request(api_method, nil, options))
|
165
|
+
response_valid? response
|
166
|
+
new(response['YourMembership_Response'][api_method]['ExportID'])
|
167
|
+
end
|
168
|
+
|
169
|
+
def update_export_uri(status_response)
|
170
|
+
@export_uri = status_response['ExportURI']
|
171
|
+
end
|
172
|
+
|
173
|
+
# Convert YourMembership API codes to readable symbols
|
174
|
+
#
|
175
|
+
# @see https://api.yourmembership.com/reference/2_00/Sa_Export_Status.htm
|
176
|
+
#
|
177
|
+
# @param [Integer] status The status code
|
178
|
+
# @return [Symbol] The status as a Symbol
|
179
|
+
def convert_status(status)
|
180
|
+
case status
|
181
|
+
when '-1'
|
182
|
+
return :failure
|
183
|
+
when '0'
|
184
|
+
return :unknown
|
185
|
+
when '1'
|
186
|
+
return :working
|
187
|
+
when '2'
|
188
|
+
return :complete
|
189
|
+
else
|
190
|
+
return :error
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|