bloomerang_api 0.2.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 12419c1537204bdc71893c92afe16c7b2a289e01c85ce54bb5abcbe64f98f89f
4
+ data.tar.gz: f574f0aab37184607b8db02121e3d405fb61ca2a362b710b74f5719dd8032d82
5
+ SHA512:
6
+ metadata.gz: 3304cdfacf46810a4cbf16a03959626792734d8ded999c85b70707d407927f14239403f98c1a6d579e107c2dfaf20db575c501919c2e96812965765f1660b427
7
+ data.tar.gz: 05f2d08d94b4cb4a9e4d98641b45a94491f42e108e9ed912f4256adc2abf97b3c7067702389d5e6839bae8c1df5e9f2c2d72b0ee229a13d2aff3aa26dc373a54
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ rubocop: warning
13
+
14
+ Style/OptionalBooleanParameter:
15
+ Enabled: false
16
+
17
+ Layout/LineLength:
18
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-03-10
4
+
5
+ - Initial release by [@allynfolksjr](https://github.com/allynfolksjr) from https://github.com/mcsweeneys/bloomerang with base classes:
6
+ - constituent
7
+ - fund
8
+ - transaction
9
+
10
+ ## [0.2.0] - 2023-01-21
11
+
12
+ - Release by [@chiperific](https://github.com/chiperific/) from https://github.com/chiperific/bloomerang_api
13
+ - Breaking changes from v0.1.0:
14
+ - Rename `#all` methods to `#fetch`
15
+ - Rename `#show` methods to `#get`
16
+ - Addition of the following classes:
17
+ - address
18
+ - appeal
19
+ - campaign
20
+ - custom_field
21
+ - email
22
+ - email_interest
23
+ - household
24
+ - interaction
25
+ - note
26
+ - phone
27
+ - pledge
28
+ - refund
29
+ - relationship
30
+ - soft-credit
31
+ - tribute
32
+ - task
33
+ - Updates to the following classes:
34
+ - constituent
35
+ - fund
36
+ - transaction
37
+
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ As members, contributors, and leaders, we pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to chiperific@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in bloomerang.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bloomerang_api (0.2.0)
5
+ faraday (>= 2.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ faraday (2.7.4)
12
+ faraday-net_http (>= 2.0, < 3.1)
13
+ ruby2_keywords (>= 0.0.4)
14
+ faraday-net_http (3.0.2)
15
+ parallel (1.21.0)
16
+ parser (3.1.1.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.0.0)
19
+ rake (13.0.6)
20
+ regexp_parser (2.2.0)
21
+ rexml (3.2.5)
22
+ rubocop (1.25.1)
23
+ parallel (~> 1.10)
24
+ parser (>= 3.1.0.0)
25
+ rainbow (>= 2.2.2, < 4.0)
26
+ regexp_parser (>= 1.8, < 3.0)
27
+ rexml
28
+ rubocop-ast (>= 1.15.1, < 2.0)
29
+ ruby-progressbar (~> 1.7)
30
+ unicode-display_width (>= 1.4.0, < 3.0)
31
+ rubocop-ast (1.16.0)
32
+ parser (>= 3.1.1.0)
33
+ ruby-progressbar (1.11.0)
34
+ ruby2_keywords (0.0.5)
35
+ unicode-display_width (2.1.0)
36
+
37
+ PLATFORMS
38
+ arm64-darwin-21
39
+ x86_64-linux
40
+
41
+ DEPENDENCIES
42
+ bloomerang_api!
43
+ rake (~> 13.0)
44
+ rubocop (~> 1.21)
45
+
46
+ BUNDLED WITH
47
+ 2.4.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Nikky Southerland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # Bloomerang
2
+
3
+ This is an unofficial [bloomerang.co REST API v2](https://bloomerang.co/product/integrations-data-management/api/rest-api/) client for Ruby.
4
+
5
+
6
+ _Note: you must be a Bloomerang customer with an active account to access the API_
7
+
8
+ This gem is based upon the initial work of [@allynfolksjr](https://github.com/allynfolksjr) at https://github.com/mcsweeneys/bloomerang. They added limited endpoint support for:
9
+
10
+ * Constituent
11
+ * Fund
12
+ * Transaction
13
+
14
+ This gem adds support [__all__ other endpoints](https://github.com/chiperific/bloomerang_api/tree/main/lib/bloomerang), _except_:
15
+
16
+ * Processor
17
+ * User
18
+ * WalletItem
19
+
20
+
21
+ ## Installation for Ruby on Rails:
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem "bloomerang_api", "~> 0.2"
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ `$ bundle install`
32
+
33
+ Or install it yourself as:
34
+
35
+ `$ gem install bloomerang_api`
36
+
37
+ ## Setup
38
+
39
+ 1. Get your Bloomerang API Key:
40
+
41
+ - Generate your v2.0 API key from [your Bloomerang user settings](https://crm.bloomerang.co/Settings/User/Edit)
42
+
43
+ 2. Add your API key to your app using a secure method:
44
+
45
+ - [Credentials](https://edgeguides.rubyonrails.org/security.html#custom-credentials) strategy (preferred):
46
+ ```yaml
47
+ # ./config/credentials.yml
48
+ bloomerang:
49
+ api_key: myapikey
50
+ ```
51
+
52
+ - [dotenv](https://github.com/bkeepers/dotenv) strategy:
53
+ ```ruby
54
+ # ./.env
55
+ BLOOMERANG_API_KEY=myapikey
56
+ ```
57
+
58
+ - [ENV](https://blog.devgenius.io/what-are-environment-variables-in-rails-6f7e97a0b164) strategy:
59
+ ```bash
60
+ $ export BLOOMERANG_API_KEY=myapikey
61
+ ```
62
+
63
+ 3. Run the generator to create the initializer file:
64
+
65
+ ```bash
66
+ $ rails generate bloomerang:initializer
67
+ ```
68
+
69
+ ### WARNING: NO SANDBOX, PRODUCTION ONLY
70
+
71
+ Bloomerang does not offer a sandbox environment or any way to test API calls without actually affecting your production data.
72
+
73
+ __Any POST, PUT and DELETE requests will be run against your live Bloomerang account!__
74
+
75
+ [Please encourage Bloomerang](https://crm.bloomerang.co/Home/FeaturesPortal) to address this issue.
76
+
77
+ ## Usage
78
+
79
+ The standard structure of all endpoints is as follows:
80
+
81
+ - Reading records:
82
+ - `#fetch`: a GET request that returns a batch of records, 50 by default (see paging/batching below for more)
83
+ - `#get`: a GET request returns a single record that matches the provided ID
84
+
85
+ - Creating, updating and deleting records:
86
+ - `#create`: a POST request that creates a record based on the provided `body` variable.
87
+ - `#update`: a PUT request that updates a record
88
+ - `#delete`: a DELETE request that deletes a record
89
+
90
+ __It is highly recommended to reference the [documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api) to identify required and allowed attributes.__
91
+
92
+ Some `Class`es have custom endpoints. For example:
93
+
94
+ - `Bloomerang::Campaign.refresh_summaries`
95
+ - `Bloomerang::Constituent.fetch_relationships`
96
+ - `Bloomerang::Constituent.update_communication_settings`
97
+ - `Bloomerang::Constituent.search`
98
+ - `Bloomerang::CustomField.categories`
99
+
100
+ You can check [the specific class](https://github.com/chiperific/bloomerang_api/tree/main/lib/bloomerang) to check for availble methods.
101
+
102
+ ### GET requests:
103
+ Most Bloomerang GET requests have URL parameters that can be set.
104
+
105
+ Each `Class` documents the available parameters you can append to `GET` requests, you can also check each endpoints [documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api)
106
+
107
+ #### Paging / Batching support:
108
+
109
+ `#search` methods, `#fetch` methods, and methods that start with `#fetch_` have two parameters in common that allow you to fetch results in batches:
110
+
111
+ - `skip` - defaults to 0, the number of records to "skip" before returning results
112
+ - `take` - defaults to 50, the number of records to return.
113
+
114
+ Responses will include the total number of results available. For example:
115
+
116
+ ```ruby
117
+ params = { skip: 0, take: 50 }
118
+ first_fifty_constituents = Bloomerang::Constituent.fetch(params)
119
+ ```
120
+
121
+ The result will include these keys:
122
+
123
+ ```json
124
+ {
125
+ "Total": 1850,
126
+ "TotalFiltered": 1850,
127
+ "Start": 0,
128
+ "ResultCount": 50,
129
+ "Results": [
130
+ { ...
131
+ ```
132
+
133
+ `"Start"` should be equal to `skip` and `"ResultCount` should be equal to `take`.
134
+
135
+ Increase your `skip` value by your `take` value to get the next page/batch of records:
136
+
137
+ ```ruby
138
+ params = { skip: 50, take: 50 }
139
+ first_fifty_constituents = Bloomerang::Constituent.fetch(params)
140
+ ```
141
+
142
+ ```json
143
+ {
144
+ "Total": 1850,
145
+ "TotalFiltered": 1850,
146
+ "Start": 50,
147
+ "ResultCount": 50,
148
+ "Results": [
149
+ { ...
150
+ ```
151
+
152
+ ### POST/PUT/DELETE requests:
153
+ __WARNING: Bloomerang has no test/sandbox feature!__
154
+
155
+ Any POST, PUT and DELETE requests will be run against your live Bloomerang account!
156
+
157
+ __Proceed with caution!__
158
+
159
+
160
+ `#update`, and `#delete` methods require a record ID and a `body` object. Not all `Class`es implement a `#delete` endpoint.
161
+
162
+ `#create` methods require only a `body` object.
163
+
164
+ __It is highly recommended to reference the [documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api) to identify required and allowed attributes.__
165
+
166
+ ## Examples
167
+
168
+ ```ruby
169
+ # fetch the first 50 individual constituents
170
+ params = { skip: 0, take: 50, type: "Individual" }
171
+ Bloomerang::Constituent.fetch(params)
172
+
173
+ # fetch the next 50 individual constituents
174
+ params = { skip: 50, take: 50, type: "Individual" }
175
+ Bloomerang::Constituent.fetch(params)
176
+
177
+ # get the email addresses (first 50) for a constituent
178
+ params = { constituent: "12345" }
179
+ Bloomerang::Email.fetch(params)
180
+
181
+ # create a task
182
+ body = {
183
+ "DueDate": "2023-01-21",
184
+ "Subject": "Schedule meeting",
185
+ "Note": "Schedule a meeting with Tom and Sidney to request a renewed family foundation gift",
186
+ "Channel": "Email",
187
+ "Purpose": "ImpactCultivation",
188
+ "UserId": 12, # the ID of the user responsible for the task
189
+ "AccountId": 123456, # the ID of the constituent related to the task
190
+ }
191
+ Bloomerang::Task.create(body)
192
+ ```
193
+
194
+ ## Contributing
195
+
196
+ Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/chiperific/bloomerang_api/blob/main/CODE_OF_CONDUCT.md).
197
+
198
+ ## License
199
+
200
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
201
+
202
+ ## Code of Conduct
203
+
204
+ Everyone interacting in the Bloomerang API project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/chiperific/bloomerang_api/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "bloomerang"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Bloomerang
6
+ ### Bloomerang::Address
7
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses
8
+ # Id integer($int64)
9
+ # AccountId integer($int64) The ID of the constituent used in the API (not to be confused with accountNumber)
10
+ # Type AddressType Enum: [ Home, Vacation, Work ]
11
+ # Street string
12
+ # City string
13
+ # State string Must match a state in the Bloomerang CRM
14
+ # PostalCode string
15
+ # Country string Must match a country in the Bloomerang CRM
16
+ # IsPrimary boolean
17
+ # IsBad boolean
18
+ # StateAbbreviation string The 2-3 letter abbreviation for the state/province
19
+ # CountryCode string The 2 letter ISO code for the country
20
+ class Address < Base
21
+ ### Fetch all addresses
22
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses/get_addresses
23
+ #
24
+ ## Params:
25
+ # skip integer, default: 0, simple paging system
26
+ # take integer, default: 50, simple paging system
27
+ # constituent array[integer], separated by pipes: "1|2|3"
28
+ # id array[integer], separated by pipes: "1|2|3"
29
+ def fetch(params = {})
30
+ get("addresses", params)
31
+ end
32
+
33
+ ### Show an address
34
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses/get_address__id_
35
+ #
36
+ ## Params:
37
+ # id integer
38
+ def get(id)
39
+ get("addresses/#{id}")
40
+ end
41
+
42
+ ### Create an address
43
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses/post_address
44
+ #
45
+ # Params:
46
+ # body see API for fields
47
+ def create(body)
48
+ post("address", {}, body)
49
+ end
50
+
51
+ ### Update an address
52
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses/put_address__id_
53
+ #
54
+ # Params:
55
+ # id integer
56
+ # body see API for fields
57
+ def update(id, body)
58
+ put("address/#{id}", {}, body)
59
+ end
60
+
61
+ ### Delete an address
62
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Addresses/delete_address__id_
63
+ #
64
+ # Params:
65
+ # id integer
66
+ def delete(id)
67
+ delete("address/#{id}", {})
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Bloomerang
6
+ ### Bloomerang::Appeal
7
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Appeals
8
+ # Id integer($int64)
9
+ # Name string
10
+ # SortIndex integer($int32)
11
+ # IsActive boolean
12
+ class Appeal < Base
13
+ ### Fetch all appeals
14
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Appeals/get_appeals
15
+ #
16
+ # Params:
17
+ # skip integer, default: 0, simple paging system
18
+ # take integer, default: 50, simple paging system
19
+ # id array[integer], separated by pipes: "1|2|3"
20
+ # isActive boolean, Filters to either active or inactive appeals
21
+ # search string, Filters to appeals with names that match any part of the search string
22
+ def fetch(params)
23
+ get("appeals", params)
24
+ end
25
+
26
+ ### Show an appeal
27
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Appeals/get_appeal__id_
28
+ #
29
+ # Params:
30
+ # id integer
31
+ def get(id)
32
+ get("appeal/#{id}")
33
+ end
34
+
35
+ ### Create an appeal
36
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Appeals/post_appeal
37
+ #
38
+ # Params:
39
+ # body see API for fields
40
+ def create(body)
41
+ post("appeal", {}, body)
42
+ end
43
+
44
+ ### Update an appeal
45
+ ## https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Appeals/put_appeal__id_
46
+ #
47
+ # Params:
48
+ # id integer
49
+ # body see API for fields
50
+ def update(id, body)
51
+ put("appeal/#{id}", {}, body)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "json"
5
+
6
+ module Bloomerang
7
+ ## Bloomerang::Base
8
+ # Primary interface for Faraday
9
+ class Base
10
+ API_URL = "https://api.bloomerang.co/v2"
11
+ API_KEY = ENV["BLOOMERANG_API_KEY"]
12
+
13
+ def get(path, params = {})
14
+ response = connection(params).get(path)
15
+ JSON.parse response.body
16
+ end
17
+
18
+ def delete(path, params = {})
19
+ response = connection(params).delete(path)
20
+ JSON.parse response.body
21
+ end
22
+
23
+ def post(path, params, body)
24
+ response = connection(params).post(path, body.to_json)
25
+ JSON.parse response.body
26
+ end
27
+
28
+ def put(path, params, body)
29
+ response = connection(params).put(path, body.to_json)
30
+ JSON.parse response.body
31
+ end
32
+
33
+ private
34
+
35
+ def connection(params)
36
+ Faraday.new(
37
+ url: API_URL,
38
+ headers: {
39
+ "Content-Type" => "application/json",
40
+ "X-API-Key" => API_KEY
41
+ },
42
+ params: params
43
+ )
44
+ end
45
+ end
46
+ end