church-community-builder 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  PROJECT_GEM = 'church-community-builder'
3
- PROJECT_GEM_VERSION = '0.1.0'
3
+ PROJECT_GEM_VERSION = '0.1.1'
4
4
 
5
5
  s.name = PROJECT_GEM
6
6
  s.version = PROJECT_GEM_VERSION
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ subdomain = '*** YOUR CHURCH SUBDOMAIN ***'
4
+ username = '*** YOUR CHURCH API USERNAME ***'
5
+ password = '*** YOUR CHURCH API PASSWORD ***'
6
+
7
+ ChurchCommunityBuilder::Api.connect(username, password, subdomain)
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../lib/ccb_api.rb'
4
+ require File.dirname(__FILE__) + '/api_connect.rb'
4
5
 
5
6
  # Load batch by id
6
7
  batch_1 = ChurchCommunityBuilder::Search.search_for_batch_by_id(469)
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../lib/ccb_api'
4
+ require File.dirname(__FILE__) + '/api_connect.rb'
4
5
  require 'pp'
5
6
 
6
7
  campus_list = ChurchCommunityBuilder::Search.search_for_all_campuses
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../lib/ccb_api'
4
+ require File.dirname(__FILE__) + '/api_connect.rb'
4
5
 
5
6
  # IndividualList is returned from Search
6
7
  x_names = ChurchCommunityBuilder::Search.search_for_person_by_name("x")
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'debugger'
3
+ require File.dirname(__FILE__) + '/../lib/ccb_api'
4
+ require File.dirname(__FILE__) + '/api_connect.rb'
5
+
6
+ ChurchCommunityBuilder
7
+
8
+ # IndividualList
9
+ profiles = ChurchCommunityBuilder::Search.all_individual_profiles
10
+
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'debugger'
4
4
  require File.dirname(__FILE__) + '/../lib/ccb_api'
5
+ require File.dirname(__FILE__) + '/api_connect.rb'
5
6
 
6
7
 
7
8
  start_date = "2013-04-01"
@@ -2,26 +2,27 @@ module ChurchCommunityBuilder
2
2
 
3
3
  class Search
4
4
 
5
+ # Returns a list of all individual profiles in the Church Community Builder system.
6
+ def self.all_individual_profiles
7
+ options = {url_data_params: {srv: 'individual_profiles'}}
8
+ reader = IndividualListReader.new(options)
9
+ IndividualList.new(reader.load_feed)
10
+ end
11
+
5
12
  # Search CCB for individuals based off of the search parameters
6
13
  # Note:
7
14
  # Searches are performed as a LIKE query in the CCB database.
8
15
  # If the value provided for the criterion is found anywhere in the field,
9
16
  # it will be considered a match.
10
17
  def self.search_for_person_by_name(last_name = nil,first_name = nil)
11
- options = {:url_data_params => {srv: "individual_search",
12
- last_name: last_name,
13
- first_name: first_name
14
- }
15
- }
18
+ options = {url_data_params: {srv: 'individual_search', last_name: last_name, first_name: first_name}}
16
19
  reader = IndividualListReader.new(options)
17
20
  IndividualList.new(reader.load_feed)
18
21
  end
19
22
 
20
23
  # Returns a list of all individuals in the Church Community Builder system.
21
24
  def self.search_for_all_valid_individuals
22
- options = {:url_data_params => {srv: "valid_individuals" }
23
-
24
- }
25
+ options = {url_data_params: {srv: 'valid_individuals'}}
25
26
  reader = IndividualListReader.new(options)
26
27
  ValidIndividualList.new(reader.load_feed)
27
28
  end
@@ -34,10 +35,7 @@ module ChurchCommunityBuilder
34
35
  #
35
36
  # Date format should be YYYY-MM-DD
36
37
  def self.search_for_batch_by_date(modified_since = nil)
37
- options = {:url_data_params => {srv: "batch_profiles",
38
- modified_since: modified_since
39
- }
40
- }
38
+ options = {url_data_params: {srv: 'batch_profiles', modified_since: modified_since} }
41
39
  reader = BatchListReader.new(options)
42
40
  BatchList.new(reader.load_feed)
43
41
  end
@@ -47,11 +45,7 @@ module ChurchCommunityBuilder
47
45
  #
48
46
  # Date format should be YYYY-MM-DD
49
47
  def self.search_for_batch_by_date_range(start_date, end_date = nil)
50
- options = {:url_data_params => {srv: "batch_profiles_in_date_range",
51
- date_start: start_date,
52
- date_end: end_date
53
- }
54
- }
48
+ options = {url_data_params: {srv: 'batch_profiles_in_date_range', date_start: start_date, date_end: end_date}}
55
49
  options[:url_data_params].delete(:date_end) if end_date.nil?
56
50
  reader = BatchListReader.new(options)
57
51
  BatchList.new(reader.load_feed)
@@ -69,9 +63,7 @@ module ChurchCommunityBuilder
69
63
  # This is currently undocumented, but found via spelunking
70
64
  #
71
65
  def self.search_for_all_campuses
72
- options = {:url_data_params => {srv: "campus_list" }
73
-
74
- }
66
+ options = {url_data_params: {srv: 'campus_list'}}
75
67
  reader = CampusListReader.new(options)
76
68
  CampusList.new(reader.load_feed)
77
69
  end
@@ -19,8 +19,13 @@ module ChurchCommunityBuilder
19
19
  Typhoeus::Request.delete(url, {:headers => headers, :params => params})
20
20
  end
21
21
 
22
-
23
- unless response.success?
22
+ # Need to account for this
23
+ # {"ccb_api"=>{"request"=>{"parameters"=>{"argument"=>[{"name"=>"srv", "value"=>"batch_profiles_in_date_range"},
24
+ # {"name"=>"date_start", "value"=>"2013-03-11"}, {"name"=>"date_end", "value"=>"2013-04-10"}]}},
25
+ # "response"=>{"error"=>{"number"=>"005", "type"=>"Service Permission", "content"=>"Query limit of '10000' reached, please try again tomorrow."}}}}
26
+ if response.body.include?('Query limit of \'10000\' reached, please try again tomorrow.')
27
+ raise ChurchCommunityBuilderExceptions::ChurchCommunityBuilderResponseError.new(response.body)
28
+ elsif !response.success?
24
29
  if response.code > 0
25
30
  raise ChurchCommunityBuilderExceptions::UnableToConnectToChurchCommunityBuilder.new(response.body)
26
31
  else
@@ -33,7 +38,7 @@ module ChurchCommunityBuilder
33
38
  raise ChurchCommunityBuilderExceptions::ChurchCommunityBuilderResponseError.new(error_messages)
34
39
  end
35
40
  end
36
- end
41
+ end
37
42
 
38
43
  response
39
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: church-community-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-16 00:00:00.000000000 Z
13
+ date: 2013-09-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus
@@ -66,10 +66,12 @@ files:
66
66
  - docs/individual_profile_implement.pdf
67
67
  - docs/pwt_implement.pdf
68
68
  - docs/pwt_overview.pdf
69
+ - examples/api_connect.rb
69
70
  - examples/batch.rb
70
71
  - examples/calendar.rb
71
72
  - examples/campus.rb
72
73
  - examples/individual.rb
74
+ - examples/individual_profiles.rb
73
75
  - examples/sync_data.rb
74
76
  - lib/api/address.rb
75
77
  - lib/api/api_object.rb