stbaldricks 4.5.0 → 4.5.1.alpha.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53c2d07ee4c230a689311946fa5429514022200b404121a67d312bea8cea8300
4
- data.tar.gz: 1f77fadca3cee1b606ad35a1b631466feeaf664113c045e7fb581361a37ee476
3
+ metadata.gz: 8aee495073a0386c3ac288ef9f754c0730a341cceeade3d2ee19827f8ac40564
4
+ data.tar.gz: c173494aba2b397fa847e663d6a1ffede523783998cc2ce0696f20c18ff8aefc
5
5
  SHA512:
6
- metadata.gz: 3759276e30a880ff1405a19499c682915aec6ff07d1dc02d28f75b9b890aff77895e0ac33a75531d297a3625f4337968a2c998c1a6478e1d420b0f86fca07ef3
7
- data.tar.gz: d1b75e4ec182a9c5ec0e83facea056316f833b3ba84f99d2006bf85503c0261c0d780054a29b7fa5c49c8e665bfbd2e73860103163a26eae25555936e3f41d12
6
+ metadata.gz: b14d4b72c4fe55a01559462712f997cc6ccec1ae91739e5fedbe0f349b454699298865b7d6ae21fdd148adf7ed0d4b9dd92cc89b4ad1bcc1a673412c1aaad9f2
7
+ data.tar.gz: 3f1a1433db08393ca97d870a1ae901af2d275a9c0ab4ac5bae3aacafb35590494e9829e096ef0540dba900ce08f88f1089e7c66093f2abfb68acf0d63c8bb283
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  `gem install stbaldricks`
5
5
 
6
6
  ### Configuration
7
- * The sdk is configured using environment variables.
7
+ * The SDK is configured using environment variables.
8
8
  * Required configurations:
9
9
  ```
10
10
  API_ENDPOINT="https://stbaldricks.org/api"
@@ -18,7 +18,7 @@ API_KEY="abc123"
18
18
  * Configure the log level (optional)
19
19
  `SBF::Client::Configuration.logger.level = ::Logger::WARN`
20
20
 
21
- * **NOTE** the sdk does not raise execptions for failed requests. This is to allow for more complex logic around error scenarios.
21
+ * **NOTE** the SDK does not raise exceptions for failed requests. This is to allow for more complex logic around error scenarios.
22
22
  * If you would like the client to raise errors by default you can wrap your requests in a helper
23
23
  ``` ruby
24
24
  def request_helper
@@ -48,7 +48,7 @@ active_donation_count = request_helper {
48
48
  puts "Beginning number of active donations: #{active_donation_count[:id]}"
49
49
  ```
50
50
 
51
- * Use `get` to get an entity by it's id fields
51
+ * Use `get` to get an entity by its id fields
52
52
  ``` ruby
53
53
  existing_donation = request_helper { SBF::Client::Donation.get(188) }
54
54
  puts "Donation: #{JSON.pretty_generate(existing_donation.to_hash)}"
@@ -118,10 +118,10 @@ puts JSON.pretty_generate(participants_and_fundraisers)
118
118
 
119
119
  ##### Filtered Search
120
120
  ``` ruby
121
- # Find all active events, teams, and fundraisers at the railyard event
121
+ # Find all active participants, teams, and fundraisers at the railyard event
122
122
  railyard_event = request_helper { SBF::Client::Event.find(venue: {location: {name: {like: "%Rail%"}}}, year: 2017) }[:results].first
123
123
 
124
- model_types = [SBF::Client::Search::Type::EVENT, SBF::Client::Search::Type::TEAM, SBF::Client::Search::Type::FUNDRAISER]
124
+ model_types = [SBF::Client::Search::Type::PARTICIPANT, SBF::Client::Search::Type::TEAM, SBF::Client::Search::Type::FUNDRAISER]
125
125
  filter = {
126
126
  and: [
127
127
  {column: 'status_id', operator: 'equals', value: SBF::Client::Search::Status::ACTIVE},
@@ -141,7 +141,7 @@ require 'geocoder'
141
141
  data = Geocoder::Lookup.get(:google).search("Lincoln, NE").first
142
142
  lat = data.latitude.round(6)
143
143
  lon = data.longitude.round(6)
144
- geo_location = {lat: lat, lon: lon, distance: 200}
144
+ geo_location = {lat: lat, lon: lon, distance: 10}
145
145
 
146
146
  model_type = SBF::Client::Search::Type::PARTICIPANT
147
147
 
@@ -151,3 +151,41 @@ active_participant_within_10_mi = request_helper { SBF::Client::Search.find(mode
151
151
  puts JSON.pretty_generate(active_participant_within_10_mi)
152
152
  ```
153
153
 
154
+ ## Architecture
155
+ | Component | Location
156
+ |--------------------|------------------------------|
157
+ | Endpoints | `/lib/stbaldricks/endpoints` |
158
+ | Entities | `/lib/stbaldricks/entities` |
159
+ | Enums | `/lib/stbaldricks/enums` |
160
+ | Rspec Unit | `/spec/unit` |
161
+ | Rspec Integration | `/spec/integration` |
162
+
163
+ ### Endpoints
164
+ * Define supported requests that can be made to the SBF API for entities in the client library.
165
+ * Extend `SBF::Client::EntityEndpoint` to receive common core action for the entities.
166
+ * If additional or non-standard functionality is required, actions can be added or overridden.
167
+ * Return a response object which will contain an http status code and depending on the code either error details
168
+ or the expected API response data for a successful request.
169
+
170
+ ### Entities
171
+ * Object representations of the data sent to and received from the API.
172
+ * Top-level entities (those that can be directly requested or modified via the API) inherit from `SBF::Client::TopLevelEntity`.
173
+ * Supported actions on the entity are defined via `action` and `actions`.
174
+ * Any actions that are disallowed are blocked via `blacklist_action`.
175
+ * The entities also map to their corresponding endpoint for handling all related API requests.
176
+ * Sub-entities should still extend the `SBF::Client::BaseEntity`.
177
+
178
+ ### Enums
179
+ * Collections of constants to assist with specifying values within a finite list.
180
+
181
+ ### Rspec Tests
182
+ Tests are broken out into unit and integration tests. Test coverage thresholds are enforced and test additions or modifications are
183
+ required for nearly any client library change.
184
+
185
+ More detail on understanding and writing Rspec tests can be found in the [Rspec Guide](https://github.com/firespring/sbf/tree/master/documentation/guides/rspec).
186
+
187
+ #### Running Tests
188
+ * use `rake client:ruby:test:all` to run all tests
189
+ * use `rake client:ruby:test:integration` to run all integration tests
190
+ * use `rake client:ruby:test:unit` to run all unit tests
191
+ * use `rake client:ruby:test:rspec TESTS={path-to-test}` to run specific test(s)
@@ -0,0 +1,37 @@
1
+ require 'stbaldricks/endpoints/user'
2
+
3
+ module SBF
4
+ module Client
5
+ module Facebook
6
+ class UserEndpoint < SBF::Client::UserEndpoint
7
+ # Logs in a user, using a Facebook Oauth authorization code & redirect uri.
8
+ # Configures the client library to use user credentials for subsequent requests.
9
+ # Returns the SBF access token for the user that should be held onto to configure the client library in
10
+ # future requests that are outside of this scope.
11
+ #
12
+ # @param authorization_code [string]
13
+ # @param redirect_uri [string]
14
+ # @return [string]
15
+ def login!(authorization_code, redirect_uri)
16
+ response = SBF::Client::Api::Request.post_request(
17
+ "/#{SBF::Client::Api::VERSION}/security/facebook/login",
18
+ authorization_code: authorization_code,
19
+ redirect_uri: redirect_uri
20
+ )
21
+ parsed_response = JSON.parse(response.body).symbolize!
22
+
23
+ if ok?(response)
24
+ SBF::Client::Configuration.user_token = parsed_response[:token]
25
+ data = parsed_response.merge(user: target_class.new(parsed_response[:user]))
26
+ SBF::Client::LOG.info { "SBF::Client - Facebook User Login with Identifier: #{parsed_response[:user][:identifier]}" }
27
+ else
28
+ SBF::Client::Configuration.user_token = nil
29
+ error = SBF::Client::ErrorEntity.new(parsed_response)
30
+ end
31
+
32
+ SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -67,13 +67,11 @@ module SBF
67
67
  password: password
68
68
  )
69
69
 
70
- if ok?(response)
71
- SBF::Client::Configuration.user_token = nil
72
- else
73
- SBF::Client::Configuration.user_token = nil
70
+ unless ok?(response)
74
71
  parsed_response = JSON.parse(response.body).symbolize!
75
72
  error = SBF::Client::ErrorEntity.new(parsed_response)
76
73
  end
74
+ SBF::Client::Configuration.user_token = nil
77
75
 
78
76
  SBF::Client::LOG.info { "SB::Client - Change Password for user with profile_id: #{profile_id}" }
79
77
  SBF::Client::Api::Response.new(http_code: response.code, data: nil, error: error)
@@ -0,0 +1,12 @@
1
+ require 'stbaldricks/entities/user'
2
+ require 'stbaldricks/endpoints/facebook/user'
3
+
4
+ module SBF
5
+ module Client
6
+ module Facebook
7
+ class User < SBF::Client::User
8
+ endpoint SBF::Client::Facebook::UserEndpoint
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module SBF
2
2
  module Client
3
- VERSION = '4.5.0'
3
+ VERSION = '4.5.1.alpha.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stbaldricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.5.1.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
@@ -85,6 +85,7 @@ files:
85
85
  - lib/stbaldricks/endpoints/contact.rb
86
86
  - lib/stbaldricks/endpoints/event.rb
87
87
  - lib/stbaldricks/endpoints/event_application.rb
88
+ - lib/stbaldricks/endpoints/facebook/user.rb
88
89
  - lib/stbaldricks/endpoints/fund.rb
89
90
  - lib/stbaldricks/endpoints/kid.rb
90
91
  - lib/stbaldricks/endpoints/kid_honor.rb
@@ -139,6 +140,7 @@ files:
139
140
  - lib/stbaldricks/entities/event_donation_summary.rb
140
141
  - lib/stbaldricks/entities/event_participant_summary.rb
141
142
  - lib/stbaldricks/entities/event_supporter.rb
143
+ - lib/stbaldricks/entities/facebook/user.rb
142
144
  - lib/stbaldricks/entities/fund.rb
143
145
  - lib/stbaldricks/entities/fundraiser.rb
144
146
  - lib/stbaldricks/entities/grant.rb
@@ -217,9 +219,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
219
  version: '0'
218
220
  required_rubygems_version: !ruby/object:Gem::Requirement
219
221
  requirements:
220
- - - ">="
222
+ - - ">"
221
223
  - !ruby/object:Gem::Version
222
- version: '0'
224
+ version: 1.3.1
223
225
  requirements: []
224
226
  rubyforge_project:
225
227
  rubygems_version: 2.7.5