wcc-arena 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: 00034fba0404c3acd477309cf2547603b1e24b4b
4
- data.tar.gz: ab1b9a3ee1243b075ee8ae65f9ed8050dd2b2535
3
+ metadata.gz: 2f332ecdc7d123631926b3383fcdbf607989cdd3
4
+ data.tar.gz: 790880e61fd1bfc3abf2bcf8c61c9ef3cfcb78db
5
5
  SHA512:
6
- metadata.gz: 270c2cf5f3dfeebf91b8d5629f5d675867058b8a01685382775ba8971eb5d00de6ccd20636f79bfd1161fa672c8ef0649904cbe57811707eea261c71eca7d14c
7
- data.tar.gz: a6b66fe9ecdcc8f7390d0d8b040ca31310cfb43e9db4b1e0775f7ea1324b37a514cb1c23fcff480782027d29848750f26755c2cb9294380f34635f53cf74ce3b
6
+ metadata.gz: 438d6c6d9b334781bd583b382f069c1997413335d7ae4cee98f79821f605be9bf5e93dcf18af5a4777d723c8a1b9710b83afe4086be4e83c2b741095fb8a2a16
7
+ data.tar.gz: a3ddac097befccaee154543f668e5445831428b60de3006cfe29a794ff9be1a590784ab4d5ffb0a2885a87f3a1978c82eca425c7b672dabb3d9b47f92f9a203b
@@ -1,5 +1,6 @@
1
1
  require 'wcc/arena/profile_query'
2
2
  require 'wcc/arena/profile_member_save'
3
+ require 'wcc/arena/single_profile_query'
3
4
 
4
5
  require 'wcc/arena/profile_member'
5
6
 
@@ -0,0 +1,25 @@
1
+ module WCC::Arena
2
+ class SingleProfileQuery
3
+ attr_reader :session
4
+ attr_reader :profile_id
5
+
6
+ def initialize(args={})
7
+ @session = args.fetch(:session) { WCC::Arena.config.session }
8
+ @profile_id = args.fetch(:profile_id)
9
+ end
10
+
11
+ def call
12
+ Profile.new(response_profile_xml) if response_profile_xml
13
+ end
14
+
15
+ private
16
+
17
+ def response_profile_xml
18
+ query_response.xml.root.xpath("/Profile")[0]
19
+ end
20
+
21
+ def query_response
22
+ @response ||= session.get("profile/#{profile_id}")
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module WCC
2
2
  module Arena
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0"?>
2
+ <Profile xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
3
+ <Active>true</Active>
4
+ <ActiveBranch>true</ActiveBranch>
5
+ <ActiveMembers>31699</ActiveMembers>
6
+ <BlobLink/>
7
+ <CampusID>-1</CampusID>
8
+ <CampusName/>
9
+ <ChildProfilesLink>profile/3094/list</ChildProfilesLink>
10
+ <CreatedBy>bob</CreatedBy>
11
+ <DateCreated>2011-10-10T09:49:38.557</DateCreated>
12
+ <DateModified>2011-10-10T09:49:38.557</DateModified>
13
+ <DormantMembers>7626</DormantMembers>
14
+ <EndTime>1900-01-01T00:00:00</EndTime>
15
+ <Guid>a4ba0388-42ed-4a4c-a0a0-a78a28a75925</Guid>
16
+ <HierarchyLevel>-1</HierarchyLevel>
17
+ <MembersLink>profile/3094/member/list</MembersLink>
18
+ <ModifiedBy>bob</ModifiedBy>
19
+ <Name>Awesome</Name>
20
+ <Notes/>
21
+ <OrganizationID>1</OrganizationID>
22
+ <OwnerID>199659</OwnerID>
23
+ <OwnerLink>person/30766779-0332-493b-960c-af66936f97f3</OwnerLink>
24
+ <ParentProfileLink/>
25
+ <ProfileActiveMemberCount>2</ProfileActiveMemberCount>
26
+ <ProfileID>3094</ProfileID>
27
+ <ProfileMemberCount>3</ProfileMemberCount>
28
+ <ProfileTypeID>1</ProfileTypeID>
29
+ <ProfileTypeValue>Ministry</ProfileTypeValue>
30
+ <QualifierID>-1</QualifierID>
31
+ <QualifierValue>Unknown</QualifierValue>
32
+ <StartTime>1900-01-01T00:00:00</StartTime>
33
+ <Summary/>
34
+ <Title>Awesomingle</Title>
35
+ <TotalMembers>39325</TotalMembers>
36
+ </Profile>
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe WCC::Arena::SingleProfileQuery do
4
+ include FixturesHelpers
5
+
6
+ subject { described_class.new(args) }
7
+ let(:args) {
8
+ {
9
+ session: double("session"),
10
+ profile_id: rand(100)
11
+ }
12
+ }
13
+
14
+ describe "#initialize" do
15
+ it "sets the session ivar" do
16
+ query = described_class.new(args)
17
+ expect(query.session).to eq(args[:session])
18
+ end
19
+
20
+ it "defaults session to global config value" do
21
+ args.delete(:session)
22
+ query = described_class.new(args)
23
+ expect(query.session).to eq(WCC::Arena.config.session)
24
+ end
25
+
26
+ it "requires a profile_id argument" do
27
+ args.delete(:profile_id)
28
+ expect { described_class.new(args) }.to raise_error(KeyError)
29
+ end
30
+ end
31
+
32
+ describe "#call" do
33
+ let(:fixture_response) { xml_fixture_response("profile.xml") }
34
+
35
+ it "makes a get request to /profile/:profile_id with query params" do
36
+ expect(subject.session).to receive(:get)
37
+ .with("profile/#{subject.profile_id}").and_return(fixture_response)
38
+ subject.()
39
+ end
40
+
41
+ it "returns a single Profile object" do
42
+ subject.session.stub(:get) { fixture_response }
43
+ record = subject.()
44
+ expect(record).to be_a(WCC::Arena::Profile)
45
+ expect(record.name).to eq("Awesome")
46
+ expect(record.active_members).to eq(31699)
47
+ end
48
+
49
+ it "returns nil when profile not found" do
50
+ subject.session
51
+ .stub(:get) { xml_fixture_response("person_not_found.xml") }
52
+ expect(subject.()).to be_nil
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-arena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Petticrew
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-23 00:00:00.000000000 Z
12
+ date: 2015-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -125,6 +125,7 @@ files:
125
125
  - lib/wcc/arena/session.rb
126
126
  - lib/wcc/arena/signed_path.rb
127
127
  - lib/wcc/arena/single_person_query.rb
128
+ - lib/wcc/arena/single_profile_query.rb
128
129
  - lib/wcc/arena/version.rb
129
130
  - spec/fixtures/group_member_list.xml
130
131
  - spec/fixtures/modify_result_failure.xml
@@ -134,6 +135,7 @@ files:
134
135
  - spec/fixtures/person_group_list.xml
135
136
  - spec/fixtures/person_list.xml
136
137
  - spec/fixtures/person_not_found.xml
138
+ - spec/fixtures/profile.xml
137
139
  - spec/fixtures/profile_list.xml
138
140
  - spec/fixtures/profile_member_list.xml
139
141
  - spec/fixtures/profile_member_save.xml
@@ -160,6 +162,7 @@ files:
160
162
  - spec/wcc/arena/session_spec.rb
161
163
  - spec/wcc/arena/signed_path_spec.rb
162
164
  - spec/wcc/arena/single_person_query_spec.rb
165
+ - spec/wcc/arena/single_profile_query_spec.rb
163
166
  - wcc-arena.gemspec
164
167
  homepage: https://github.com/watermarkchurch/wcc-arena
165
168
  licenses:
@@ -184,35 +187,35 @@ rubyforge_project:
184
187
  rubygems_version: 2.4.2
185
188
  signing_key:
186
189
  specification_version: 4
187
- summary: "# WCC::Arena This gem provides wrappers to the Arena church management
188
- system's API. This is an early version of the library, and has had limited testing
190
+ summary: '# WCC::Arena This gem provides wrappers to the Arena church management
191
+ system''s API. This is an early version of the library, and has had limited testing
189
192
  in real world environments. Use at your own risk! There are also bound to be a
190
- few things that are specific to our configuration and version of Arena. This isn't
193
+ few things that are specific to our configuration and version of Arena. This isn''t
191
194
  intentional and we consider that a bug that we would like to fix. We would love
192
- for this to be a fully featured way to interact with Arena's API. ## Installation
193
- \ Add this line to your application's Gemfile: gem 'wcc-arena' And then execute:
194
- \ $ bundle Or install it yourself as: $ gem install wcc-arena ## Configuration
195
- \ You can configure the wcc-arena gem using the `WCC::Arena.configure` method. Here
196
- is an example configuration block: ```ruby WCC::Arena.configure do |arena| arena.username
197
- = 'username' arena.password = 'password' arena.api_key = 'api_key' arena.api_secret
198
- = 'api_secret' arena.api_url = 'https://arena-domain/api.svc/' end ``` ## Usage
199
- \ The library is currently a very thin layer over the Arena API. We plan to add
200
- a higher level interface layer that provides a better experience for the most common
201
- use cases. The library consists of Query classes and Mapper classes. The Query
202
- classes handle calling the respective services and the Mapper classes handle binding
203
- the XML to Ruby objects. For full details on all available endpoints please see
204
- the code. Below are a few examples of some common queries. ```ruby person_query
205
- = WCC::Arena::PersonQuery.new.where(first_name: \"Travis\") people = person_query.call
206
- people.each do |person| puts person.full_name end ``` This will print the full names
207
- of all person records with the first name \"Travis\". There are a ton of other attributes
208
- that are available on a Person record. Check them out on the [Person](https://github.com/watermarkchurch/wcc-arena/blob/master/lib/wcc/arena/person.rb)
195
+ for this to be a fully featured way to interact with Arena''s API. ## Installation Add
196
+ this line to your application''s Gemfile: gem ''wcc-arena'' And then execute: $
197
+ bundle Or install it yourself as: $ gem install wcc-arena ## Configuration You
198
+ can configure the wcc-arena gem using the `WCC::Arena.configure` method. Here is
199
+ an example configuration block: ```ruby WCC::Arena.configure do |arena| arena.username
200
+ = ''username'' arena.password = ''password'' arena.api_key = ''api_key'' arena.api_secret
201
+ = ''api_secret'' arena.api_url = ''https://arena-domain/api.svc/'' end ``` ## Usage The
202
+ library is currently a very thin layer over the Arena API. We plan to add a higher
203
+ level interface layer that provides a better experience for the most common use
204
+ cases. The library consists of Query classes and Mapper classes. The Query classes
205
+ handle calling the respective services and the Mapper classes handle binding the
206
+ XML to Ruby objects. For full details on all available endpoints please see the
207
+ code. Below are a few examples of some common queries. ```ruby person_query = WCC::Arena::PersonQuery.new.where(first_name:
208
+ "Travis") people = person_query.call people.each do |person| puts person.full_name
209
+ end ``` This will print the full names of all person records with the first name
210
+ "Travis". There are a ton of other attributes that are available on a Person record.
211
+ Check them out on the [Person](https://github.com/watermarkchurch/wcc-arena/blob/master/lib/wcc/arena/person.rb)
209
212
  model. You can also query tags (or Profiles as they are called under the hood).
210
213
  To pull all top level Ministry tags run the following: ```ruby # This assumes that
211
214
  your ministry tags have a type ID of 1. WCC::Arena::ProfileQuery.new(profile_type_id:
212
215
  1).call.each do |tag| puts tag.name end ``` ## Contributing 1. Fork it 2. Create
213
216
  your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git
214
- commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`)
215
- 5. Create new Pull Request"
217
+ commit -am ''Add some feature''`) 4. Push to the branch (`git push origin my-new-feature`)
218
+ 5. Create new Pull Request'
216
219
  test_files:
217
220
  - spec/fixtures/group_member_list.xml
218
221
  - spec/fixtures/modify_result_failure.xml
@@ -222,6 +225,7 @@ test_files:
222
225
  - spec/fixtures/person_group_list.xml
223
226
  - spec/fixtures/person_list.xml
224
227
  - spec/fixtures/person_not_found.xml
228
+ - spec/fixtures/profile.xml
225
229
  - spec/fixtures/profile_list.xml
226
230
  - spec/fixtures/profile_member_list.xml
227
231
  - spec/fixtures/profile_member_save.xml
@@ -248,3 +252,4 @@ test_files:
248
252
  - spec/wcc/arena/session_spec.rb
249
253
  - spec/wcc/arena/signed_path_spec.rb
250
254
  - spec/wcc/arena/single_person_query_spec.rb
255
+ - spec/wcc/arena/single_profile_query_spec.rb