wcc-arena 0.1.0 → 0.2.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: 847a7b9b46ead985eb00221fb3ce685215671746
4
- data.tar.gz: 7ce4cea280b3de3c7761e64619d5d3af2083caab
3
+ metadata.gz: 78c775b268d1495b0152e28aae31f6f6ad495b33
4
+ data.tar.gz: 373f450d5c5e8a9ae3ec92df844f19175fc9010e
5
5
  SHA512:
6
- metadata.gz: 23dda6c3fc79b84e9934f985c73ebc1d64dff57244b5780c24e05c8bbebb0d0a995dbf955398f5f941afc9dc7f9d1898b408d80b18cd0e3ee3cbd3861fe81d72
7
- data.tar.gz: 5b504562dd6e74c74fec426714500952a07a6410facf94f41765df9b7753487502aebe295efa6622daf75f1cb7154b2ee46e240079bf1934c00f8988e8d35839
6
+ metadata.gz: 3dad2d3af57efabe8fede201ac7f1acc1e29356c30bc6b15307758943168c10f2b78d45b208ac0a1bd6212518f92fd788d98c5d29ea062e280282657138d988e
7
+ data.tar.gz: 193c355b203bfd6cde237e4c22888d7eb78a800f31a5bc4361561270c353b4bfe3ea9531fa8799f1454e63a744310f1183bcdb266ebf5e1d3e7d1a646ae1845b
data/README.md CHANGED
@@ -38,7 +38,7 @@ WCC::Arena.configure do |arena|
38
38
  arena.api_secret = 'api_secret'
39
39
  arena.api_url = 'https://arena-domain/api.svc/'
40
40
  end
41
- ```end
41
+ ```
42
42
 
43
43
  ## Usage
44
44
 
@@ -53,14 +53,27 @@ available endpoints please see the code. Below are a few examples of
53
53
  some common queries.
54
54
 
55
55
  ```ruby
56
- query = WCC::Arena::PersonQuery.new.where(first_name: "Travis")
57
- people = query.call
56
+ person_query = WCC::Arena::PersonQuery.new.where(first_name: "Travis")
57
+ people = person_query.call
58
58
  people.each do |person|
59
59
  puts person.full_name
60
60
  end
61
61
  ```
62
62
  This will print the full names of all person records with the first name
63
- "Travis".
63
+ "Travis". There are a ton of other attributes that are available on a
64
+ Person record. Check them out on the
65
+ [Person](https://github.com/watermarkchurch/wcc-arena/blob/master/lib/wcc/arena/person.rb)
66
+ model.
67
+
68
+ You can also query tags (or Profiles as they are called under the hood).
69
+ To pull all top level Ministry tags run the following:
70
+
71
+ ```ruby
72
+ # This assumes that your ministry tags have a type ID of 1.
73
+ WCC::Arena::ProfileQuery.new(profile_type_id: 1).call.each do |tag|
74
+ puts tag.name
75
+ end
76
+ ```
64
77
 
65
78
  ## Contributing
66
79
 
data/bin/autospec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -1,5 +1,4 @@
1
1
  module WCC::Arena
2
-
3
2
  class GroupQuery
4
3
  attr_reader :session
5
4
  attr_reader :person_id
@@ -12,15 +11,14 @@ module WCC::Arena
12
11
  end
13
12
 
14
13
  def call
15
- response_groups_xml.collect do |person_xml|
16
- Group.new(person_xml)
17
- end
14
+ groups = response_groups_xml.map { |person_xml| Group.new(person_xml) }
15
+ groups.uniq { |g| g.id }
18
16
  end
19
17
 
20
18
  private
21
19
 
22
20
  def response_groups_xml
23
- query_response.xml.root.xpath("Groups/Group")
21
+ query_response.xml.root.xpath("Groups/Group[not(LeaderID='-1')]")
24
22
  end
25
23
 
26
24
  def query_response
@@ -29,8 +27,5 @@ module WCC::Arena
29
27
  categoryid: category_id
30
28
  )
31
29
  end
32
-
33
-
34
30
  end
35
-
36
31
  end
@@ -1,4 +1,5 @@
1
1
  require 'wcc/arena/person_query'
2
+ require 'wcc/arena/single_person_query'
2
3
 
3
4
  require 'wcc/arena/address'
4
5
  require 'wcc/arena/email'
@@ -9,7 +9,7 @@ module WCC::Arena
9
9
  attribute :person_id, xpath: "PersonInformation/PersonID", type: :integer
10
10
 
11
11
  def person
12
- @person ||= PersonQuery.new.where(person_id: person_id).()[0]
12
+ @person ||= SinglePersonQuery.new(person_id: person_id).()
13
13
  end
14
14
 
15
15
  end
@@ -0,0 +1,25 @@
1
+ module WCC::Arena
2
+ class SinglePersonQuery
3
+ attr_reader :session
4
+ attr_reader :person_id
5
+
6
+ def initialize(args={})
7
+ @session = args.fetch(:session) { WCC::Arena.config.session }
8
+ @person_id = args.fetch(:person_id)
9
+ end
10
+
11
+ def call
12
+ Person.new(response_person_xml)
13
+ end
14
+
15
+ private
16
+
17
+ def response_person_xml
18
+ query_response.xml.root.xpath("/Person")[0]
19
+ end
20
+
21
+ def query_response
22
+ @response ||= session.get("person/#{person_id}")
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module WCC
2
2
  module Arena
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -48,5 +48,88 @@
48
48
  <TopicID>500050</TopicID>
49
49
  <TopicValue>Unknown</TopicValue>
50
50
  </Group>
51
+ <Group>
52
+ <Active>true</Active>
53
+ <AreaID>9</AreaID>
54
+ <AreaName>North Dallas Area</AreaName>
55
+ <AverageAge>27</AverageAge>
56
+ <Description/>
57
+ <GroupClusterID>1378</GroupClusterID>
58
+ <GroupClusterTitle>Small Group Awesome</GroupClusterTitle>
59
+ <GroupID>1407</GroupID>
60
+ <GroupTypeID>-1</GroupTypeID>
61
+ <GroupTypeValue>Unknown</GroupTypeValue>
62
+ <GroupUrl/>
63
+ <Guid>56d153b5-9c30-41d8-9f0c-c566d42ecde8</Guid>
64
+ <ImageBlobLink/>
65
+ <LeaderID>168827</LeaderID>
66
+ <LeaderLink>person/168827</LeaderLink>
67
+ <MaxMembers>20</MaxMembers>
68
+ <MeetingDayID>9</MeetingDayID>
69
+ <MeetingDayValue>Sunday</MeetingDayValue>
70
+ <MeetingEndTime>1900-01-01T00:00:00</MeetingEndTime>
71
+ <MeetingStartTime>1900-01-01T00:00:00</MeetingStartTime>
72
+ <MemberLink>group/1407/member/list</MemberLink>
73
+ <Name>Small Group Awesome</Name>
74
+ <Notes/>
75
+ <PictureUrl/>
76
+ <PrimaryAgeID>337</PrimaryAgeID>
77
+ <PrimaryAgeValue>Any</PrimaryAgeValue>
78
+ <PrimaryMaritalStatusID>338</PrimaryMaritalStatusID>
79
+ <PrimaryMaritalStatusValue>Any</PrimaryMaritalStatusValue>
80
+ <Schedule/>
81
+ <TargetLocation>
82
+ <AddressID>115364</AddressID>
83
+ <City>Dallas</City>
84
+ <Country>US</Country>
85
+ <Latitude>32.019239</Latitude>
86
+ <Longitude>-97.296295</Longitude>
87
+ <PostalCode>75000-1234</PostalCode>
88
+ <Primary>true</Primary>
89
+ <State>TX</State>
90
+ <StreetLine1>123 Main St</StreetLine1>
91
+ <StreetLine2/>
92
+ </TargetLocation>
93
+ <TargetLocationID>168827</TargetLocationID>
94
+ <Title>Small Group Awesome</Title>
95
+ <TopicID>500050</TopicID>
96
+ <TopicValue>Unknown</TopicValue>
97
+ </Group>
98
+ <Group>
99
+ <Active>true</Active>
100
+ <AreaID>10</AreaID>
101
+ <AreaName>North Dallas Area</AreaName>
102
+ <AverageAge>27</AverageAge>
103
+ <Description/>
104
+ <GroupClusterID>1379</GroupClusterID>
105
+ <GroupClusterTitle>Small Group Awesome</GroupClusterTitle>
106
+ <GroupID>1408</GroupID>
107
+ <GroupTypeID>-1</GroupTypeID>
108
+ <GroupTypeValue>Unknown</GroupTypeValue>
109
+ <GroupUrl/>
110
+ <Guid>56d153b5-9c30-41d8-9f0c-c566d42ecef9</Guid>
111
+ <ImageBlobLink/>
112
+ <LeaderID>-1</LeaderID>
113
+ <LeaderLink>person/168828</LeaderLink>
114
+ <MaxMembers>20</MaxMembers>
115
+ <MeetingDayID>9</MeetingDayID>
116
+ <MeetingDayValue>Sunday</MeetingDayValue>
117
+ <MeetingEndTime>1900-01-01T00:00:00</MeetingEndTime>
118
+ <MeetingStartTime>1900-01-01T00:00:00</MeetingStartTime>
119
+ <MemberLink>group/1408/member/list</MemberLink>
120
+ <Name>Small Group Awesome</Name>
121
+ <Notes/>
122
+ <PictureUrl/>
123
+ <PrimaryAgeID>337</PrimaryAgeID>
124
+ <PrimaryAgeValue>Any</PrimaryAgeValue>
125
+ <PrimaryMaritalStatusID>338</PrimaryMaritalStatusID>
126
+ <PrimaryMaritalStatusValue>Any</PrimaryMaritalStatusValue>
127
+ <Schedule/>
128
+ <TargetLocation/>
129
+ <TargetLocationID>168828</TargetLocationID>
130
+ <Title>Small Group Awesome</Title>
131
+ <TopicID>500051</TopicID>
132
+ <TopicValue>Unknown</TopicValue>
133
+ </Group>
51
134
  </Groups>
52
135
  </GroupListResult>
@@ -38,19 +38,28 @@ describe WCC::Arena::GroupQuery do
38
38
 
39
39
  describe "#call" do
40
40
  let(:fixture_response) { xml_fixture_response("person_group_list.xml") }
41
+ let(:list) { subject.() }
41
42
 
42
43
  it "does a get request to the person group list service" do
43
44
  expect(subject.session).to receive(:get).with("person/45/group/list", categoryid: 1).and_return(fixture_response)
44
- subject.()
45
+ list
45
46
  end
46
47
 
47
48
  it "returns an array of Group objects" do
48
49
  subject.session.stub(:get) { fixture_response }
49
- list = subject.()
50
50
  list.each do |item|
51
51
  expect(item).to be_a(WCC::Arena::Group)
52
52
  end
53
53
  end
54
- end
55
54
 
55
+ it "excludes deleted groups" do
56
+ subject.session.stub(:get) { fixture_response }
57
+ expect(list.map(&:leader_id)).to_not include(-1)
58
+ end
59
+
60
+ it "returns groups with unique IDs" do
61
+ subject.session.stub(:get) { fixture_response }
62
+ expect(list.map(&:id).uniq.size).to eq(list.size)
63
+ end
64
+ end
56
65
  end
@@ -22,18 +22,17 @@ describe WCC::Arena::ProfileMember do
22
22
  end
23
23
 
24
24
  describe "#person method" do
25
+ let(:person_id) { 123 }
25
26
  before(:each) do
26
- subject.stub(:person_id) { 123 }
27
+ subject.stub(:person_id) { person_id }
27
28
  end
28
29
 
29
- it "fetchs builds and executes a PersonQuery on the person_id attribute" do
30
- person_query = double(:person_query)
31
- expect(WCC::Arena::PersonQuery).to receive(:new).and_return(person_query).once
32
- expect(person_query).to receive(:where).with(person_id: 123).and_return(-> { [:record] })
30
+ it "fetchs builds and executes a SinglePersonQuery on the person_id attribute" do
31
+ expect(WCC::Arena::SinglePersonQuery).to receive(:new).once
32
+ .with(person_id: person_id).and_return(-> { :record })
33
33
  expect(subject.person).to eq(:record)
34
34
  expect(subject.person).to eq(:record)
35
35
  end
36
-
37
36
  end
38
37
 
39
38
  end
@@ -88,7 +88,7 @@ describe WCC::Arena::Session do
88
88
 
89
89
  describe "#expires" do
90
90
  it "returns the DateExpires from the credentialing API call" do
91
- expect(subject.expires).to be_within(1).of(Time.new(2213, 12, 20, 14, 46, 43))
91
+ expect(subject.expires).to be_within(1).of(Time.new(2213, 12, 20, 14, 46, 43, "-06:00"))
92
92
  end
93
93
  end
94
94
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe WCC::Arena::SinglePersonQuery do
4
+ include FixturesHelpers
5
+
6
+ subject { described_class.new(args) }
7
+ let(:args) {
8
+ {
9
+ session: double("session"),
10
+ person_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 person_id argument" do
27
+ args.delete(:person_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("person.xml") }
34
+
35
+ it "makes a get request to /person/list with query params" do
36
+ expect(subject.session).to receive(:get)
37
+ .with("person/#{subject.person_id}").and_return(fixture_response)
38
+ subject.()
39
+ end
40
+
41
+ it "returns a single Person object" do
42
+ subject.session.stub(:get) { fixture_response }
43
+ record = subject.()
44
+ expect(record).to be_a(WCC::Arena::Person)
45
+ expect(record.first_name).to eq("Donald")
46
+ expect(record.last_name).to eq("Duck")
47
+ end
48
+ end
49
+ 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.1.0
4
+ version: 0.2.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: 2014-09-10 00:00:00.000000000 Z
12
+ date: 2015-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -85,7 +85,9 @@ description: Watermark's library for interfacing with Arena ChMS's web API
85
85
  email:
86
86
  - travis@petticrew.net
87
87
  - dev@watermark.org
88
- executables: []
88
+ executables:
89
+ - autospec
90
+ - rspec
89
91
  extensions: []
90
92
  extra_rdoc_files: []
91
93
  files:
@@ -95,6 +97,8 @@ files:
95
97
  - LICENSE.txt
96
98
  - README.md
97
99
  - Rakefile
100
+ - bin/autospec
101
+ - bin/rspec
98
102
  - lib/wcc/arena.rb
99
103
  - lib/wcc/arena/address.rb
100
104
  - lib/wcc/arena/config.rb
@@ -120,6 +124,7 @@ files:
120
124
  - lib/wcc/arena/response.rb
121
125
  - lib/wcc/arena/session.rb
122
126
  - lib/wcc/arena/signed_path.rb
127
+ - lib/wcc/arena/single_person_query.rb
123
128
  - lib/wcc/arena/version.rb
124
129
  - spec/fixtures/group_member_list.xml
125
130
  - spec/fixtures/modify_result_failure.xml
@@ -153,6 +158,7 @@ files:
153
158
  - spec/wcc/arena/response_spec.rb
154
159
  - spec/wcc/arena/session_spec.rb
155
160
  - spec/wcc/arena/signed_path_spec.rb
161
+ - spec/wcc/arena/single_person_query_spec.rb
156
162
  - wcc-arena.gemspec
157
163
  homepage: https://github.com/watermarkchurch/wcc-arena
158
164
  licenses:
@@ -174,33 +180,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
180
  version: '0'
175
181
  requirements: []
176
182
  rubyforge_project:
177
- rubygems_version: 2.2.2
183
+ rubygems_version: 2.4.2
178
184
  signing_key:
179
185
  specification_version: 4
180
- summary: '# WCC::Arena This gem provides wrappers to the Arena church management
181
- system''s API. This is an early version of the library, and has had limited testing
186
+ summary: "# WCC::Arena This gem provides wrappers to the Arena church management
187
+ system's API. This is an early version of the library, and has had limited testing
182
188
  in real world environments. Use at your own risk! There are also bound to be a
183
- few things that are specific to our configuration and version of Arena. This isn''t
189
+ few things that are specific to our configuration and version of Arena. This isn't
184
190
  intentional and we consider that a bug that we would like to fix. We would love
185
- for this to be a fully featured way to interact with Arena''s API. ## Installation Add
186
- this line to your application''s Gemfile: gem ''wcc-arena'' And then execute: $
187
- bundle Or install it yourself as: $ gem install wcc-arena ## Configuration You
188
- can configure the wcc-arena gem using the `WCC::Arena.configure` method. Here is
189
- an example configuration block: ```ruby WCC::Arena.configure do |arena| arena.username
190
- = ''username'' arena.password = ''password'' arena.api_key = ''api_key'' arena.api_secret
191
- = ''api_secret'' arena.api_url = ''https://arena-domain/api.svc/'' end ```end ##
192
- Usage The library is currently a very thin layer over the Arena API. We plan to
193
- add a higher level interface layer that provides a better experience for the most
194
- common use cases. The library consists of Query classes and Mapper classes. The
195
- Query classes handle calling the respective services and the Mapper classes handle
196
- binding the XML to Ruby objects. For full details on all available endpoints please
197
- see the code. Below are a few examples of some common queries. ```ruby query =
198
- WCC::Arena::PersonQuery.new.where(first_name: "Travis") people = query.call people.each
199
- do |person| puts person.full_name end ``` This will print the full names of all
200
- person records with the first name "Travis". ## Contributing 1. Fork it 2. Create
191
+ for this to be a fully featured way to interact with Arena's API. ## Installation
192
+ \ Add this line to your application's Gemfile: gem 'wcc-arena' And then execute:
193
+ \ $ bundle Or install it yourself as: $ gem install wcc-arena ## Configuration
194
+ \ You can configure the wcc-arena gem using the `WCC::Arena.configure` method. Here
195
+ is an example configuration block: ```ruby WCC::Arena.configure do |arena| arena.username
196
+ = 'username' arena.password = 'password' arena.api_key = 'api_key' arena.api_secret
197
+ = 'api_secret' arena.api_url = 'https://arena-domain/api.svc/' end ``` ## Usage
198
+ \ The library is currently a very thin layer over the Arena API. We plan to add
199
+ a higher level interface layer that provides a better experience for the most common
200
+ use cases. The library consists of Query classes and Mapper classes. The Query
201
+ classes handle calling the respective services and the Mapper classes handle binding
202
+ the XML to Ruby objects. For full details on all available endpoints please see
203
+ the code. Below are a few examples of some common queries. ```ruby person_query
204
+ = WCC::Arena::PersonQuery.new.where(first_name: \"Travis\") people = person_query.call
205
+ people.each do |person| puts person.full_name end ``` This will print the full names
206
+ of all person records with the first name \"Travis\". There are a ton of other attributes
207
+ 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)
208
+ model. You can also query tags (or Profiles as they are called under the hood).
209
+ To pull all top level Ministry tags run the following: ```ruby # This assumes that
210
+ your ministry tags have a type ID of 1. WCC::Arena::ProfileQuery.new(profile_type_id:
211
+ 1).call.each do |tag| puts tag.name end ``` ## Contributing 1. Fork it 2. Create
201
212
  your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git
202
- commit -am ''Add some feature''`) 4. Push to the branch (`git push origin my-new-feature`)
203
- 5. Create new Pull Request'
213
+ commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`)
214
+ 5. Create new Pull Request"
204
215
  test_files:
205
216
  - spec/fixtures/group_member_list.xml
206
217
  - spec/fixtures/modify_result_failure.xml
@@ -234,3 +245,4 @@ test_files:
234
245
  - spec/wcc/arena/response_spec.rb
235
246
  - spec/wcc/arena/session_spec.rb
236
247
  - spec/wcc/arena/signed_path_spec.rb
248
+ - spec/wcc/arena/single_person_query_spec.rb