shelby-arena-api 0.1.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.
@@ -0,0 +1,45 @@
1
+ module ShelbyArena
2
+
3
+ class PersonListReader < ApiReader
4
+
5
+ # Constructor.
6
+ def initialize(options = {})
7
+ # page = options[:page] || 1
8
+ # per_page = options[:per_page] || 100
9
+
10
+ @url_data_params = {}
11
+ valid_fields.each { |field| @url_data_params[field] = options[ShelbyArena::attr_underscore(field).to_sym] unless options[ShelbyArena::attr_underscore(field).to_sym].nil? }
12
+ @url_data_path = 'person/list'
13
+ end
14
+
15
+ def valid_fields
16
+ %W(Address
17
+ altID
18
+ areaId
19
+ birthdate
20
+ email
21
+ giftID
22
+ loginID
23
+ firstName
24
+ lastName
25
+ personID
26
+ phone
27
+ profileID
28
+ onlyConnected
29
+ searchDistance
30
+ latitude
31
+ longitude
32
+ campusID
33
+ includeInactive
34
+ memberStatus
35
+ attributeID
36
+ attributeIntValue
37
+ attributeVarcharValue
38
+ attributeDateTimeValue
39
+ attributeDecimalValue
40
+ name).sort
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,21 @@
1
+ module ShelbyArena
2
+
3
+ class PersonReader < ApiReader
4
+
5
+ # Constructor.
6
+ #
7
+ # @param person_id (optional) The ID of the person to load.
8
+ def initialize(person_id = nil)
9
+ if person_id.nil?
10
+ raise 'The create endpoint is not known yet.'
11
+ @url_new_data_path = nil # Not sure yet
12
+ else
13
+ @url_data_path = "person/#{person_id}"
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+
@@ -0,0 +1,37 @@
1
+ require 'typhoeus'
2
+ require 'json'
3
+ require 'xmlsimple'
4
+
5
+ # The path to the lib directory.
6
+ SHELBY_ARENA_LIB_DIR = File.dirname(__FILE__)
7
+
8
+ require File.dirname(__FILE__) + '/auto_load.rb'
9
+
10
+ require File.dirname(__FILE__) + '/common.rb'
11
+
12
+ module ShelbyArena
13
+
14
+ class Api
15
+
16
+ class << self
17
+ attr_reader :username, :password, :api_key, :api_secret, :service_url, :session_key
18
+ end
19
+
20
+ def self.request_session(username, password, api_key, service_url)
21
+ @username = username
22
+ @password = password
23
+ @api_key = api_key
24
+ @service_url = service_url
25
+ ShelbySession.new(ShelbyArena.request_session)
26
+ end
27
+
28
+ def self.connect(session_key, api_secret, service_url)
29
+ @session_key = session_key
30
+ @api_secret = api_secret
31
+ @service_url = service_url
32
+ true
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,76 @@
1
+ module ShelbyArena
2
+
3
+ # This class is the base class for all ShelbyArena objects and is meant to be inherited.
4
+ #
5
+ class ApiWriter
6
+ attr_reader :error_messages, :response_code
7
+
8
+ end
9
+ end
10
+
11
+
12
+
13
+ # module FellowshipOne
14
+
15
+ # # This adapter is the standard for all saving objects.
16
+ # class ApiWriter
17
+ # attr_reader :error_messages, :response_code
18
+
19
+ # # Saves this object.
20
+ # #
21
+ # # @return True or ID on success, otherwise false.
22
+ # def save_object
23
+ # @url_data_params ||= {}
24
+ # success = true
25
+
26
+ # if @url_data_path.nil?
27
+ # @error_messages = ["#{@url_action.to_s.upcase} not implemented for #{self.class.to_s}"]
28
+ # return false
29
+ # end
30
+
31
+ # if @updatable_fields and !@updatable_fields.empty?
32
+ # # fields_to_remove = @url_data_params.keys - @updatable_fields
33
+ # # fields_to_remove.each { |ftr| @url_data_params.delete(ftr) }
34
+ # end
35
+
36
+ # begin
37
+ # response = FellowshipOne::api_request(@url_action, @url_data_path, [], @url_data_params.to_json)
38
+ # @response_code = response.code
39
+ # # No content but is a success
40
+ # success = response.code == 204 ? {'success' => true} : JSON.parse(response.body)
41
+ # rescue Exception => e
42
+ # @error_messages = e.message.split(',')
43
+ # success = false
44
+ # end
45
+
46
+ # return success
47
+ # end
48
+
49
+
50
+ # # Deletes this object.
51
+ # #
52
+ # # @return True or ID on success, otherwise false.
53
+ # def delete_object
54
+ # success = true
55
+
56
+ # if @url_data_delete_path.nil?
57
+ # @error_messages = ["DELETE not implemented for #{self.class.to_s}"]
58
+ # return false
59
+ # end
60
+
61
+ # begin
62
+ # # @url_data_path should be the same as :put if this object is already
63
+ # # setup and mapped to an object that exists
64
+ # response = FellowshipOne::api_request(:delete, @url_data_delete_path)
65
+ # success = response.code == 204 ? true : false # No content but is a success
66
+ # rescue Exception => e
67
+ # @error_messages = e.message.split(',')
68
+ # success = false
69
+ # end
70
+
71
+ # return success
72
+ # end
73
+
74
+ # end
75
+
76
+ # end
@@ -0,0 +1,64 @@
1
+ module ShelbyArena
2
+
3
+ class PersonWriter < ApiWriter
4
+
5
+ # Constructor.
6
+ #
7
+ # @param data The json object data to save.
8
+ def initialize(data)
9
+ if data[:id]
10
+ @url_action = :put
11
+ @url_data_path = "/v1/People/#{data[:id]}"
12
+ else
13
+ @url_action = :post
14
+ @url_data_path = "/v1/People"
15
+ end
16
+ @url_data_delete_path = "/v1/People/#{data[:id]}"
17
+
18
+ @url_data_params = {'person' => data}
19
+
20
+ @updatable_fields = [:title,
21
+ :salutation,
22
+ :prefix,
23
+ :first_name,
24
+ :last_name, #required
25
+ :suffix,
26
+ :middle_name,
27
+ :goes_by_name,
28
+ :former_name,
29
+ :gender,
30
+ :date_of_birth,
31
+ :marital_status,
32
+ :household_member_type, #required
33
+ :is_authorized,
34
+ :status, #required
35
+ :occupation,
36
+ :employer,
37
+ :school,
38
+ :denomination,
39
+ :former_church,
40
+ :bar_code,
41
+ :member_envelope_code,
42
+ :default_tag_comment,
43
+ :weblink,
44
+ :solicit,
45
+ :thank,
46
+ :first_record,
47
+ :last_match_date,
48
+ :created_date,
49
+ :last_updated_date,
50
+ :id,
51
+ :uri,
52
+ :image_uri,
53
+ :old_id,
54
+ :i_code,
55
+ :household_id, #required
56
+ :old_household_id,
57
+ :attributes,
58
+ :addresses,
59
+ :communications]
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ PROJECT_GEM = 'shelby-arena-api'
3
+ PROJECT_GEM_VERSION = '0.1.0'
4
+
5
+ s.name = PROJECT_GEM
6
+ s.version = PROJECT_GEM_VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+
9
+ s.homepage = 'https://github.com/weshays/shelby-arena-api-ruby'
10
+ s.rubyforge_project = 'Project on www.github.com'
11
+ s.authors = ['Wes Hays']
12
+ s.email = ['weshays@gbdev.com']
13
+
14
+ s.summary = 'Ruby gem/plugin to interact with the Shelby Arena API'
15
+ s.description = 'Ruby gem/plugin to interact with the Shelby Arena API. Checkout the project on github for more detail.'
16
+
17
+ s.add_dependency('typhoeus', '0.6.6')
18
+ s.add_dependency('virtus', '1.0.2')
19
+
20
+
21
+ s.files = `git ls-files`.split("\n").delete_if { |f| !(f =~ /^examples/).nil? }
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'ShelbyArenaApi' do
4
+
5
+ before do
6
+ #simulate_connection_to_server
7
+ end
8
+
9
+ after do
10
+
11
+ end
12
+
13
+ it 'should connect successfully'
14
+
15
+ end
16
+
17
+
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe ShelbyArena::ApiReader do
4
+
5
+ it 'should pass'
6
+
7
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path( File.dirname(__FILE__) + '/../example/shelby_arena_keys.rb')
2
+ require File.expand_path( File.dirname(__FILE__) + '/../lib/shelby_arena.rb')
3
+
4
+ require 'debugger'
5
+
6
+ require 'vcr'
7
+ require 'vcr_setup'
8
+ require 'webmock/rspec'
9
+
10
+ Dir.glob(File.dirname(__FILE__) + "/factories/*").each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
23
+
24
+
25
+ def simulate_connection_to_server
26
+ ShelbyArena::Api.connect(ShelbyArenaKeys::USERNAME,
27
+ ShelbyArenaKeys::PASSWORD,
28
+ ShelbyArenaKeys::API_KEY,
29
+ ShelbyArenaKeys::API_SECRET,
30
+ ShelbyArenaKeys::SHELBY_ARENA_SERVICE_URL)
31
+ end
@@ -0,0 +1,5 @@
1
+ VCR.configure do |config|
2
+ config.cassette_library_dir = 'spec/cassettes'
3
+ config.hook_into :webmock
4
+ config.default_cassette_options = { :record => :once, :erb => true }
5
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe ShelbyArena::ApiWriter do
4
+
5
+ it 'should pass'
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shelby-arena-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wes Hays
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: virtus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.2
41
+ description: Ruby gem/plugin to interact with the Shelby Arena API. Checkout the project
42
+ on github for more detail.
43
+ email:
44
+ - weshays@gbdev.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - .ruby-gemset
51
+ - .ruby-version
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - README.rdoc
55
+ - Rakefile
56
+ - docs/ArenaAPI.pdf
57
+ - lib/api/address.rb
58
+ - lib/api/api_object.rb
59
+ - lib/api/contribution.rb
60
+ - lib/api/contribution_list.rb
61
+ - lib/api/family.rb
62
+ - lib/api/fund.rb
63
+ - lib/api/fund_list.rb
64
+ - lib/api/person.rb
65
+ - lib/api/person_list.rb
66
+ - lib/api/shelby_session.rb
67
+ - lib/auto_load.rb
68
+ - lib/common.rb
69
+ - lib/exceptions.rb
70
+ - lib/readers/api_reader.rb
71
+ - lib/readers/contribution_list_reader.rb
72
+ - lib/readers/contribution_reader.rb
73
+ - lib/readers/family_reader.rb
74
+ - lib/readers/fund_list_reader.rb
75
+ - lib/readers/fund_reader.rb
76
+ - lib/readers/person_list_reader.rb
77
+ - lib/readers/person_reader.rb
78
+ - lib/shelby_arena.rb
79
+ - lib/writers/api_writer.rb
80
+ - lib/writers/person_writer.rb
81
+ - shelby_arena_api.gemspec
82
+ - spec/functional/shelby_arena_spec.rb
83
+ - spec/readers/api_reader_spec.rb
84
+ - spec/spec_helper.rb
85
+ - spec/vcr_helper.rb
86
+ - spec/writers/api_writer_spec.rb
87
+ homepage: https://github.com/weshays/shelby-arena-api-ruby
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project: Project on www.github.com
106
+ rubygems_version: 2.1.11
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Ruby gem/plugin to interact with the Shelby Arena API
110
+ test_files:
111
+ - spec/functional/shelby_arena_spec.rb
112
+ - spec/readers/api_reader_spec.rb
113
+ - spec/spec_helper.rb
114
+ - spec/vcr_helper.rb
115
+ - spec/writers/api_writer_spec.rb