stbaldricks 1.5.1.pre

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.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/lib/stbaldricks.rb +2 -0
  4. data/lib/stbaldricks/api.rb +7 -0
  5. data/lib/stbaldricks/api_connector.rb +47 -0
  6. data/lib/stbaldricks/client.rb +7 -0
  7. data/lib/stbaldricks/configuration.rb +47 -0
  8. data/lib/stbaldricks/default_logger.rb +24 -0
  9. data/lib/stbaldricks/endpoints/communicate.rb +67 -0
  10. data/lib/stbaldricks/endpoints/config.rb +18 -0
  11. data/lib/stbaldricks/endpoints/contact.rb +12 -0
  12. data/lib/stbaldricks/endpoints/event.rb +39 -0
  13. data/lib/stbaldricks/endpoints/event_application.rb +32 -0
  14. data/lib/stbaldricks/endpoints/fund.rb +24 -0
  15. data/lib/stbaldricks/endpoints/kid.rb +24 -0
  16. data/lib/stbaldricks/endpoints/kid_honor.rb +17 -0
  17. data/lib/stbaldricks/endpoints/lib/entity.rb +247 -0
  18. data/lib/stbaldricks/endpoints/message.rb +27 -0
  19. data/lib/stbaldricks/endpoints/newsletter_recipient.rb +41 -0
  20. data/lib/stbaldricks/endpoints/participant.rb +66 -0
  21. data/lib/stbaldricks/endpoints/photo.rb +51 -0
  22. data/lib/stbaldricks/endpoints/recurring_gift.rb +18 -0
  23. data/lib/stbaldricks/endpoints/search.rb +63 -0
  24. data/lib/stbaldricks/endpoints/shave_schedule.rb +28 -0
  25. data/lib/stbaldricks/endpoints/user.rb +106 -0
  26. data/lib/stbaldricks/entities/batch.rb +29 -0
  27. data/lib/stbaldricks/entities/campaign.rb +37 -0
  28. data/lib/stbaldricks/entities/communicate.rb +20 -0
  29. data/lib/stbaldricks/entities/config.rb +41 -0
  30. data/lib/stbaldricks/entities/contact.rb +40 -0
  31. data/lib/stbaldricks/entities/contact_group.rb +29 -0
  32. data/lib/stbaldricks/entities/document_library.rb +19 -0
  33. data/lib/stbaldricks/entities/document_library_category.rb +14 -0
  34. data/lib/stbaldricks/entities/donation.rb +372 -0
  35. data/lib/stbaldricks/entities/donation/donor_type.rb +13 -0
  36. data/lib/stbaldricks/entities/donation/how_created.rb +22 -0
  37. data/lib/stbaldricks/entities/donation/payment_type.rb +17 -0
  38. data/lib/stbaldricks/entities/donation/promo_code.rb +22 -0
  39. data/lib/stbaldricks/entities/donation/recipient_type.rb +17 -0
  40. data/lib/stbaldricks/entities/donation/special_donation_type.rb +78 -0
  41. data/lib/stbaldricks/entities/donation/status.rb +12 -0
  42. data/lib/stbaldricks/entities/donation/submitter_type.rb +13 -0
  43. data/lib/stbaldricks/entities/donor.rb +15 -0
  44. data/lib/stbaldricks/entities/event.rb +173 -0
  45. data/lib/stbaldricks/entities/event/fund_relationship_type.rb +15 -0
  46. data/lib/stbaldricks/entities/event/how_created.rb +14 -0
  47. data/lib/stbaldricks/entities/event/promo_code.rb +11 -0
  48. data/lib/stbaldricks/entities/event/status.rb +13 -0
  49. data/lib/stbaldricks/entities/event/sub_type.rb +16 -0
  50. data/lib/stbaldricks/entities/event/type.rb +12 -0
  51. data/lib/stbaldricks/entities/event_application.rb +135 -0
  52. data/lib/stbaldricks/entities/event_application/model_type.rb +15 -0
  53. data/lib/stbaldricks/entities/event_application/status.rb +23 -0
  54. data/lib/stbaldricks/entities/event_donation_summary.rb +18 -0
  55. data/lib/stbaldricks/entities/event_participant_summary.rb +17 -0
  56. data/lib/stbaldricks/entities/event_supporter.rb +24 -0
  57. data/lib/stbaldricks/entities/fund.rb +98 -0
  58. data/lib/stbaldricks/entities/fundraiser.rb +124 -0
  59. data/lib/stbaldricks/entities/international_partner.rb +58 -0
  60. data/lib/stbaldricks/entities/kid.rb +190 -0
  61. data/lib/stbaldricks/entities/kid_honor.rb +123 -0
  62. data/lib/stbaldricks/entities/lib/address.rb +25 -0
  63. data/lib/stbaldricks/entities/lib/base.rb +505 -0
  64. data/lib/stbaldricks/entities/lib/cacheable.rb +43 -0
  65. data/lib/stbaldricks/entities/lib/default_cacheable.rb +17 -0
  66. data/lib/stbaldricks/entities/lib/email_address.rb +15 -0
  67. data/lib/stbaldricks/entities/lib/error.rb +38 -0
  68. data/lib/stbaldricks/entities/lib/fundraising_page.rb +20 -0
  69. data/lib/stbaldricks/entities/lib/geo_location.rb +9 -0
  70. data/lib/stbaldricks/entities/lib/location.rb +27 -0
  71. data/lib/stbaldricks/entities/lib/name.rb +17 -0
  72. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +32 -0
  73. data/lib/stbaldricks/entities/lib/opt_out_settings.rb +21 -0
  74. data/lib/stbaldricks/entities/lib/payment.rb +86 -0
  75. data/lib/stbaldricks/entities/lib/permissions.rb +33 -0
  76. data/lib/stbaldricks/entities/lib/phone.rb +29 -0
  77. data/lib/stbaldricks/entities/lib/third_party_media.rb +20 -0
  78. data/lib/stbaldricks/entities/lib/top_level.rb +99 -0
  79. data/lib/stbaldricks/entities/lib/venue.rb +18 -0
  80. data/lib/stbaldricks/entities/memorial.rb +61 -0
  81. data/lib/stbaldricks/entities/message.rb +65 -0
  82. data/lib/stbaldricks/entities/newsletter_recipient.rb +17 -0
  83. data/lib/stbaldricks/entities/organization.rb +90 -0
  84. data/lib/stbaldricks/entities/page.rb +49 -0
  85. data/lib/stbaldricks/entities/participant.rb +216 -0
  86. data/lib/stbaldricks/entities/person.rb +403 -0
  87. data/lib/stbaldricks/entities/photo.rb +260 -0
  88. data/lib/stbaldricks/entities/recurring_gift.rb +215 -0
  89. data/lib/stbaldricks/entities/response.rb +37 -0
  90. data/lib/stbaldricks/entities/search.rb +223 -0
  91. data/lib/stbaldricks/entities/section.rb +15 -0
  92. data/lib/stbaldricks/entities/shave_schedule.rb +69 -0
  93. data/lib/stbaldricks/entities/summary.rb +32 -0
  94. data/lib/stbaldricks/entities/team.rb +95 -0
  95. data/lib/stbaldricks/entities/user.rb +76 -0
  96. data/lib/stbaldricks/enums/country.rb +223 -0
  97. data/lib/stbaldricks/enums/feature.rb +29 -0
  98. data/lib/stbaldricks/enums/league_status.rb +16 -0
  99. data/lib/stbaldricks/enums/model_type.rb +39 -0
  100. data/lib/stbaldricks/enums/permission.rb +223 -0
  101. data/lib/stbaldricks/enums/permission_model_type.rb +21 -0
  102. data/lib/stbaldricks/enums/province.rb +39 -0
  103. data/lib/stbaldricks/enums/state.rb +137 -0
  104. data/lib/stbaldricks/enums/top_level_category_type.rb +25 -0
  105. data/lib/stbaldricks/errors.rb +18 -0
  106. data/lib/stbaldricks/log.rb +16 -0
  107. data/lib/stbaldricks/patches/array.rb +6 -0
  108. data/lib/stbaldricks/patches/boolean.rb +25 -0
  109. data/lib/stbaldricks/patches/class.rb +13 -0
  110. data/lib/stbaldricks/patches/float.rb +9 -0
  111. data/lib/stbaldricks/patches/hash.rb +16 -0
  112. data/lib/stbaldricks/patches/integer.rb +9 -0
  113. data/lib/stbaldricks/patches/nil.rb +25 -0
  114. data/lib/stbaldricks/patches/string.rb +54 -0
  115. data/lib/stbaldricks/request.rb +146 -0
  116. data/lib/stbaldricks/version.rb +5 -0
  117. metadata +215 -0
@@ -0,0 +1,27 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class MessageEndpoint < SBF::Client::EntityEndpoint
6
+ def mark_as_read(message_id)
7
+ raise SBF::Client::Error, 'Message Id must be an Integer' unless message_id.is_a?(Integer)
8
+
9
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/mark_as_read/#{message_id}")
10
+
11
+ error = SBF::Client::ErrorEntity.new(response) unless ok?(response)
12
+
13
+ SBF::Client::Api::Response.new(http_code: response.code, data: response, error: error)
14
+ end
15
+
16
+ def mark_as_unread(message_id)
17
+ raise SBF::Client::Error, 'Message Id must be an Integer' unless message_id.is_a?(Integer)
18
+
19
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/mark_as_unread/#{message_id}")
20
+
21
+ error = SBF::Client::ErrorEntity.new(response) unless ok?(response)
22
+
23
+ SBF::Client::Api::Response.new(http_code: response.code, data: response, error: error)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class NewsletterRecipientEndpoint < EntityEndpoint
6
+ def subscribe(entity_or_email, first_name = nil, last_name = nil, welcome_email = true)
7
+ if entity_or_email.is_a?(String) && entity_or_email && first_name && last_name
8
+ entity = target_class.new(email_address: entity_or_email, first_name: first_name, last_name: last_name, welcome_email: welcome_email)
9
+ elsif entity_or_email.is_a?(SBF::Client::BaseEntity)
10
+ entity = entity_or_email
11
+ else
12
+ raise SBF::Client::Error, 'Invalid Entity'
13
+ end
14
+
15
+ data = entity.to_hash
16
+
17
+ response = SBF::Client::Api::Request.public_post_request("#{base_uri}/subscribe", data)
18
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
19
+
20
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
21
+ end
22
+
23
+ def unsubscribe(entity_or_email)
24
+ if entity_or_email.is_a?(String)
25
+ entity = target_class.new(email_address: entity_or_email)
26
+ elsif entity_or_email.is_a?(SBF::Client::BaseEntity)
27
+ entity = entity_or_email
28
+ else
29
+ raise SBF::Client::Error, 'Invalid Entity'
30
+ end
31
+
32
+ data = entity.to_hash
33
+
34
+ response = SBF::Client::Api::Request.public_post_request("#{base_uri}/unsubscribe", data)
35
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
36
+
37
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,66 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class ParticipantEndpoint < EntityEndpoint
6
+ def join_team(participant_id, new_team_id)
7
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: participant_id, new_team_id: new_team_id)
8
+
9
+ if ok?(response)
10
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
11
+ else
12
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
13
+ end
14
+
15
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
16
+ end
17
+
18
+ def start_team(participant_id, team_name, fundraising_goal)
19
+ response = SBF::Client::Api::Request.post_request(
20
+ "#{base_uri}/move_to_different_team",
21
+ id: participant_id,
22
+ new_team_id: 0,
23
+ team_name: team_name,
24
+ goal: fundraising_goal,
25
+ how_created: SBF::Client::Team::HowCreated::WEBSITE)
26
+
27
+ if ok?(response)
28
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
29
+ else
30
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
31
+ end
32
+
33
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
34
+ end
35
+
36
+ def leave_team(participant_id)
37
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_team", id: participant_id, new_team_id: 0)
38
+
39
+ if ok?(response)
40
+ data = SBF::Client::FullParticipant.new(JSON.parse(response.body).symbolize!)
41
+ else
42
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!)
43
+ end
44
+
45
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
46
+ end
47
+
48
+ def delete_role(participant_id, role)
49
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/delete_role", participant_id: participant_id, role: role)
50
+
51
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
52
+
53
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
54
+ end
55
+
56
+ def move_to_different_event(participant_id, new_event_id)
57
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/move_to_different_event",
58
+ id: participant_id, new_event_id: new_event_id)
59
+
60
+ error = SBF::Client::ErrorEntity.new(JSON.parse(response.body).symbolize!) unless ok?(response)
61
+
62
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,51 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class PhotoEndpoint < SBF::Client::EntityEndpoint
6
+ def create(entity, with = {})
7
+ raise SBF::Client::Error, 'Invalid Entity' unless entity.is_a?(SBF::Client::BaseEntity)
8
+
9
+ with = normalize_with(with)
10
+
11
+ create_data = entity.to_hash
12
+ filename = create_data.delete(:filename)
13
+ file = create_data.delete(:file)
14
+ create_data.store(:with, with)
15
+
16
+ response = SBF::Client::Api::Request.file_post_request(path: "#{base_uri}/create", params: create_data, file: file, filename: filename)
17
+
18
+ entity, error = hydrate_entity(response, create_data, entity)
19
+
20
+ SBF::Client::Api::Response.new(http_code: response.code, data: entity, error: error)
21
+ end
22
+
23
+ def update(_id = nil, entity_or_hash = nil, with = {})
24
+ if entity_or_hash.is_a?(SBF::Client::BaseEntity)
25
+ # If someone has passed in an entity, just convert it to a hash
26
+ data = entity_or_hash.to_hash
27
+ elsif entity_or_hash.is_a?(Hash)
28
+ # If someone has passed in a hash, make sure all of it's values match fields in the entity class
29
+ data = sanitize(entity_or_hash)
30
+ else
31
+ raise SBF::Client::Error, 'Invalid Data'
32
+ end
33
+
34
+ filename = data.delete(:filename)
35
+ file = data.delete(:file)
36
+
37
+ with = normalize_with(with)
38
+ data[:with] = with
39
+ response = if file
40
+ SBF::Client::Api::Request.file_post_request(path: "#{base_uri}/update", params: data, file: file, filename: filename)
41
+ else
42
+ SBF::Client::Api::Request.post_request("#{base_uri}/update", data)
43
+ end
44
+
45
+ data, error = hydrate_entity(response, data, entity_or_hash)
46
+
47
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,18 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class RecurringGiftEndpoint < SBF::Client::EntityEndpoint
6
+ def sync(data)
7
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/sync", data)
8
+
9
+ unless ok?(response)
10
+ parsed_response_body = JSON.parse(response.body).symbolize!
11
+ error = SBF::Client::ErrorEntity.new(parsed_response_body)
12
+ end
13
+
14
+ SBF::Client::Api::Response.new(http_code: response.code, data: response, error: error)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,63 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class SearchEndpoint < EntityEndpoint
6
+ # Find entities in search matching the provided search term and/or filters.
7
+ #
8
+ # @param [String|Array] model_type The type or types of entities to include in the results.
9
+ # @param [String] search_text A search term to filter the results.
10
+ # @param [Array] filters Filters to apply to the results. The array should contain hashes with the column, value and operator of the filter.
11
+ # (i.e.) [{column: 'event_id', value: [11560, 11016,11378,11163], operator: 'in'}]
12
+ # @param [Hash] geo_location The location details for performing a radius search. The hash should contain the lat, lon and distance.
13
+ # (i.e.) {distance: 5, lat: 40.754567, lon: -96.695894}
14
+ # @param [Hash] options An hash containing options for ordering, applying a limit and offset to the results.
15
+ # @option options [Hash] :order The ordering to apply to the results. The hash should contain the field_name to order on
16
+ # as well as the direction. (i.e.) {field_name: 'foo', direction: 'asc'}
17
+ # @option [Integer] :limit The maximum number of results to return.
18
+ # @option [Integer] :offset The query offset.
19
+ # @return [Client::Api::Response] The data attribute on a successful response will be
20
+ # an array of search entities matching the model type(s) specified
21
+ def find(model_type, search_text = nil, filters = [], geo_location = {}, options = {})
22
+ if [search_text, filters, geo_location].all?(&:empty?)
23
+ raise SBF::Client::Error, 'Must provide either a search_text, filter or geo_location for the query'
24
+ end
25
+
26
+ model_type = Array(model_type).to_json unless model_type.empty?
27
+ filters = filters.to_json unless filters.empty?
28
+ geo_location = geo_location.to_json unless geo_location.empty?
29
+
30
+ # Build the parameter list for search
31
+ params, response_data = {}, {}
32
+ {model_type: model_type, search_text: search_text, filters: filters, geo_location: geo_location}.each do |k, v|
33
+ params[k.to_sym] = v unless v.empty?
34
+ end
35
+
36
+ options.each do |k, v|
37
+ params[k.to_sym] = v.is_a?(Hash) ? v.to_json : v unless v.empty?
38
+ end
39
+
40
+ response = SBF::Client::Api::Request.get_request("#{base_uri}/search", params)
41
+ parsed_response_body = JSON.parse(response.body).symbolize!
42
+
43
+ if ok?(response)
44
+ parsed_response_body = JSON.parse(parsed_response_body[:response]).symbolize!
45
+
46
+ response_data[:total_count] = parsed_response_body[:hits][:total]
47
+ response_data[:results] = [].tap do |arr|
48
+ parsed_response_body[:hits][:hits].each do |entity_data|
49
+ arr << target_class.const_get(entity_data[:_type].capitalize).new(entity_data[:_source])
50
+ end
51
+ end
52
+
53
+ data = response_data
54
+ else
55
+ data = nil
56
+ error = SBF::Client::ErrorEntity.new(parsed_response_body)
57
+ end
58
+
59
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,28 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class ShaveScheduleEndpoint < SBF::Client::EntityEndpoint
6
+ def get(id, year, with = {})
7
+ super("#{id}/#{year}", with)
8
+ end
9
+
10
+ def update(id, year, data, with = {})
11
+ super("#{id}/#{year}", data, with)
12
+ end
13
+
14
+ def notify(data)
15
+ response = SBF::Client::Api::Request.post_request("#{base_uri}/notify", data)
16
+
17
+ if ok?(response)
18
+ data = nil
19
+ else
20
+ parsed_response_body = JSON.parse(response.body).symbolize!
21
+ error = SBF::Client::ErrorEntity.new(parsed_response_body)
22
+ end
23
+
24
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,106 @@
1
+ require 'stbaldricks/endpoints/lib/entity'
2
+
3
+ module SBF
4
+ module Client
5
+ class UserEndpoint < EntityEndpoint
6
+ # Logs in a user and configures the client library to use user credentials for subsequent requests.
7
+ # Returns the access token for the user that should be held onto to configure the client library in
8
+ # future requests that are outside of this scope.
9
+ #
10
+ # @param username [string]
11
+ # @param password [string]
12
+ # @return [string]
13
+ def login!(username, password)
14
+ response = SBF::Client::Api::Request.public_post_request(
15
+ "/#{SBF::Client::Api::VERSION}/security/login",
16
+ username: username,
17
+ password: password
18
+ )
19
+ parsed_response = JSON.parse(response.body).symbolize!
20
+
21
+ if ok?(response)
22
+ SBF::Client::Configuration.user_token = parsed_response[:token]
23
+ data = parsed_response.merge(user: target_class.new(parsed_response[:user]))
24
+ else
25
+ SBF::Client::Configuration.user_token = nil
26
+ error = SBF::Client::ErrorEntity.new(parsed_response)
27
+ end
28
+
29
+ SBF::Client::LOG.info { "SBF::Client - User Login: #{username}, Token: #{parsed_response[:token]}" }
30
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
31
+ end
32
+
33
+ # Returns array of entity hash info for the entities logged in user has access to for requested permission.
34
+ #
35
+ # @raise [SBFClientError]
36
+ def list_entities_user_has_permission(permission_id, event_years)
37
+ raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
38
+
39
+ event_years = [event_years] if event_years.is_a? Fixnum
40
+
41
+ response = SBF::Client::Api::Request.post_request(
42
+ "/#{SBF::Client::Api::VERSION}/security/list_entities_user_has_permission",
43
+ permission_id: permission_id,
44
+ event_years: event_years
45
+ )
46
+ parsed_response = JSON.parse(response.body).symbolize!
47
+
48
+ if ok?(response)
49
+ data = parsed_response
50
+ else
51
+ error = SBF::Client::ErrorEntity.new(parsed_response)
52
+ end
53
+
54
+ SBF::Client::LOG.info { "SBF::Client - User List Entities User Has Permission: #{permission_id}, #{event_years}, Entities: #{data}" }
55
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
56
+ end
57
+
58
+ # Changes the password of the user associated with the given profile_id
59
+ #
60
+ # @raise [SBFClientError]
61
+ def change_password(profile_id, password)
62
+ raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
63
+
64
+ response = SBF::Client::Api::Request.post_request(
65
+ "/#{SBF::Client::Api::VERSION}/security/change_password",
66
+ profile_id: profile_id,
67
+ password: password
68
+ )
69
+
70
+ if ok?(response)
71
+ SBF::Client::Configuration.user_token = nil
72
+ else
73
+ SBF::Client::Configuration.user_token = nil
74
+ parsed_response = JSON.parse(response.body).symbolize!
75
+ error = SBF::Client::ErrorEntity.new(parsed_response)
76
+ end
77
+
78
+ SBF::Client::LOG.info { "SB::Client - Change Password for user with profile_id: #{profile_id}" }
79
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
80
+ end
81
+
82
+ # Removes the Facebook user of the given profile_id
83
+ #
84
+ # @raise [SBFClientError]
85
+ def disconnect_facebook(profile_id)
86
+ raise SBF::Client::Error, 'User not logged in' if SBF::Client::Configuration.user_token.nil?
87
+
88
+ response = SBF::Client::Api::Request.post_request(
89
+ "/#{SBF::Client::Api::VERSION}/user/disconnect_facebook",
90
+ profile_id: profile_id
91
+ )
92
+
93
+ if ok?(response)
94
+ SBF::Client::Configuration.user_token = nil
95
+ else
96
+ SBF::Client::Configuration.user_token = nil
97
+ parsed_response = JSON.parse(response.body).symbolize!
98
+ error = SBF::Client::ErrorEntity.new(parsed_response)
99
+ end
100
+
101
+ SBF::Client::LOG.info { "SB::Client - Disconnecting Facebook user with profile_id: #{profile_id}" }
102
+ SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,29 @@
1
+ require 'stbaldricks/entities/donation'
2
+ require 'stbaldricks/entities/lib/top_level'
3
+ require 'stbaldricks/entities/lib/payment'
4
+
5
+ module SBF
6
+ module Client
7
+ class Batch < SBF::Client::TopLevelEntity
8
+ actions DEFAULT_CRUD_ACTIONS
9
+
10
+ module Type
11
+ IMPORTED = 'imported'
12
+ PROCESSED = 'processed'
13
+ end
14
+
15
+ attr_accessor :id
16
+ attr_accessor :type
17
+ multitype_attr_accessor(
18
+ :payment_details, [
19
+ [->(v) { v[:type] == SBF::Client::Payment::Type::CREDIT_CARD }, 'SBF::Client::Payment::CreditCardDetails'],
20
+ [->(v) { v[:type] == SBF::Client::Payment::Type::NONCE }, 'SBF::Client::Payment::NonceDetails']
21
+ ]
22
+ )
23
+ attr_accessor :amount
24
+ attr_accessor :filename
25
+ attr_accessor :created_at, :modified_at, :processed_at, :submitted_by
26
+ entity_collection_attr_accessor :donations, 'SBF::Client::FullDonation', 'SBF::Client::PartialDonation'
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ require 'stbaldricks/entities/lib/fundraising_page'
2
+ require 'stbaldricks/entities/lib/base'
3
+ require 'stbaldricks/entities/lib/top_level'
4
+
5
+ module SBF
6
+ module Client
7
+ class Campaign < SBF::Client::TopLevelEntity
8
+ action :get
9
+ action :find
10
+
11
+ disallow_instantiation
12
+
13
+ class Totals < SBF::Client::BaseEntity
14
+ attr_reader :current_year_amount_raised
15
+ attr_reader :previous_year_amount_raised
16
+ attr_reader :all_years_amount_raised
17
+ attr_reader :participants
18
+ attr_reader :shavees
19
+ end
20
+ end
21
+
22
+ class PartialCampaign < Campaign
23
+ attr_accessor :id
24
+ end
25
+
26
+ class FullCampaign < Campaign
27
+ attr_accessor :id
28
+ attr_accessor :name
29
+ attr_accessor :website_url
30
+
31
+ entity_attr_reader :totals, 'SBF::Client::Campaign::Totals', nil, true
32
+ entity_attr_accessor :web_page, 'SBF::Client::WebPage', nil, true
33
+
34
+ entity_attr_accessor :photo, 'SBF::Client::Photo', nil, true
35
+ end
36
+ end
37
+ end