rock_rms 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 501dfde931b8ef3c1295c0d7193cdc64debdab8f
4
- data.tar.gz: 807122b0f7feeedd95bab7c743cf9f3fb644d471
3
+ metadata.gz: 92eae9f2816d3de7c67efad778e7fd05a590c881
4
+ data.tar.gz: cc901d2931b7bb5847f094ef7fecfcec83b2fd3e
5
5
  SHA512:
6
- metadata.gz: c41adbfdf7cd5f3a5b5d77066b4de6e1d8fc99cf2b2b31e01291f1dec53ffe73f8c4f6163dc6ba04706b22e21144445fb465daf964611090927b4f92304b54a3
7
- data.tar.gz: b0a0e7abffbbec6314cdac13df6780601c74ad4331f15fd924fa92057693fa172e0ae1c32ef6c9213d27e3c7049f2b060473f870275f4489a9978475803f92e0
6
+ metadata.gz: 4a298ad04b5cd53f9e32be677e217bbc9c4a5464b62df59cf8fdb2a814b884aa9021af99f518bbc1a41689f8fa72b8bb20daf4d0182df3eaf2ed454e9c0f14b8
7
+ data.tar.gz: e5a568e37a6d90034765d45f4452db28a2e7e7dabbbaf7845bd881c4b0f9e9d693aa8a8ed68081661575feda1c03a8b2bf03912cedc469542f8d23c0028e6532
@@ -1,5 +1,6 @@
1
1
  require 'faraday'
2
2
  require 'faraday_middleware'
3
+ require 'faraday_middleware/parse_oj'
3
4
  require_relative 'version'
4
5
 
5
6
  Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
@@ -7,6 +8,7 @@ Dir[File.expand_path('../responses/*.rb', __FILE__)].each{|f| require f}
7
8
 
8
9
  module RockRMS
9
10
  class Client
11
+ include RockRMS::Client::Batch
10
12
  include RockRMS::Client::Donation
11
13
  include RockRMS::Client::Fund
12
14
  include RockRMS::Client::PaymentMethod
@@ -15,7 +17,7 @@ module RockRMS
15
17
  attr_reader :url, :username, :password, :logger, :cookie, :connection
16
18
 
17
19
  def initialize(url:, username:, password:, logger: true)
18
- @url = url
20
+ @url = "#{url}/api/"
19
21
  @username = username
20
22
  @password = password
21
23
  @logger = logger
@@ -23,7 +25,7 @@ module RockRMS
23
25
  end
24
26
 
25
27
  def auth
26
- connection.post("Auth/Login", {
28
+ connection.post("#{@url}Auth/Login", {
27
29
  'Username' => username,
28
30
  'Password' => password,
29
31
  'Persisted' => true
@@ -66,7 +68,7 @@ module RockRMS
66
68
  Faraday.new(url: url, headers: headers) do |conn|
67
69
  conn.request :json
68
70
  conn.response :logger if logger
69
- conn.response :json
71
+ conn.response :oj
70
72
  conn.adapter Faraday.default_adapter
71
73
  end
72
74
  end
@@ -0,0 +1,34 @@
1
+ module RockRMS
2
+ class Client
3
+ module Batch
4
+
5
+ def list_batches(options = {})
6
+ res = get(batches_path, options)
7
+ end
8
+
9
+ def find_batch(id)
10
+ res = get(batches_path(id))
11
+ end
12
+
13
+ def create_batch(options = {})
14
+ options = {
15
+ "Name" => options[:name],
16
+ "BatchStartDateTime" => options[:start_time],
17
+ "BatchEndDateTime" => options[:end_time],
18
+ }
19
+ post(batches_path, options)
20
+ end
21
+
22
+ def update_batch(id, options = {})
23
+ patch(batches_path(id), options)
24
+ end
25
+
26
+ private
27
+
28
+ def batches_path(id = nil)
29
+ id ? "FinancialBatches/#{id}" : "FinancialBatches"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -12,27 +12,28 @@ module RockRMS
12
12
  raw ? res : RockRMS::Donation.format(res)
13
13
  end
14
14
 
15
- def find_donations(id)
15
+ def find_donation(id)
16
16
  res = get(transaction_path(id))
17
17
  RockRMS::Donation.format(res)
18
18
  end
19
19
 
20
- def create_donation(authorized_person_id:, amount:, date:, fund_id:)
20
+ def create_donation(payment_type:, authorized_person_id:, amount:, date:, fund_id:, batch_id:)
21
21
  options = {
22
22
  "TransactionDateTime" => date,
23
23
  "AuthorizedPersonAliasId" => authorized_person_id,
24
24
  "TransactionDetails" => [{
25
25
  "Amount" => amount,
26
- "AccountId" => fund_id
26
+ "AccountId" => fund_id,
27
27
  }],
28
28
  "TransactionTypeValueId" => 53, # transaction type "contribution", "registration"
29
- "FinancialPaymentDetailId" => 1
29
+ "FinancialPaymentDetailId" => payment_type,
30
+ "BatchId" => batch_id
30
31
  }
31
32
  post(transaction_path, options)
32
33
  end
33
34
 
34
35
  def update_transaction(id, options={})
35
- put(transaction_path(id), options)
36
+ patch(transaction_path(id), options)
36
37
  end
37
38
 
38
39
  def delete_transaction(id)
@@ -2,7 +2,7 @@ module RockRMS
2
2
  class Client
3
3
  module Fund
4
4
 
5
- def list_funds(options={})
5
+ def list_funds(options = {})
6
6
  res = get(fund_path, options)
7
7
  RockRMS::Fund.format(res)
8
8
  end
@@ -17,10 +17,21 @@ module RockRMS
17
17
  end
18
18
 
19
19
  def find_person_by_name(full_name)
20
- res = get("People/Search?name=#{full_name}&includeHtml=false&includeDetails=false&includeBusinesses=false&includeDeceased=false")
20
+ res = get("People/Search?name=#{full_name}&includeHtml=false&includeDetails=true&includeBusinesses=false&includeDeceased=false")
21
21
  RockRMS::Person.format(res)
22
22
  end
23
23
 
24
+ def create_person(first_name:, last_name:, email:)
25
+ options = {
26
+ "IsSystem" => false,
27
+ "FirstName" => first_name,
28
+ "LastName" => last_name,
29
+ "Email" => email,
30
+ "Gender" => 1
31
+ }
32
+ post(people_path, options)
33
+ end
34
+
24
35
  def update_person(id, options = {})
25
36
  put(people_path(id), options)
26
37
  end
@@ -14,7 +14,8 @@ module RockRMS
14
14
  date: donation["TransactionDateTime"],
15
15
  amount: donation["TransactionDetails"].reduce(0){|sum, td| sum + td["Amount"]},
16
16
  person_id: donation["AuthorizedPersonAliasId"],
17
- fund: ""
17
+ fund: "",
18
+ batch_id: donation["BatchId"]
18
19
  }
19
20
  end
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/rock_rms.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_runtime_dependency 'faraday'
23
23
  s.add_runtime_dependency 'faraday_middleware'
24
+ s.add_runtime_dependency 'faraday_middleware-parse_oj'
24
25
  s.add_runtime_dependency 'json'
25
26
 
26
27
  s.add_development_dependency 'bundler'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock_rms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-01 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware-parse_oj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: json
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,7 @@ files:
80
94
  - README.md
81
95
  - lib/rock_rms.rb
82
96
  - lib/rock_rms/client.rb
97
+ - lib/rock_rms/resources/batch.rb
83
98
  - lib/rock_rms/resources/donation.rb
84
99
  - lib/rock_rms/resources/fund.rb
85
100
  - lib/rock_rms/resources/payment_method.rb
@@ -109,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
124
  version: '0'
110
125
  requirements: []
111
126
  rubyforge_project:
112
- rubygems_version: 2.5.1
127
+ rubygems_version: 2.4.8
113
128
  signing_key:
114
129
  specification_version: 4
115
130
  summary: A Ruby wrapper for the Rock RMS API