justgiving 0.1.2 → 0.1.3
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 +4 -4
- data/lib/justgiving/account.rb +23 -0
- data/lib/justgiving/charity.rb +10 -0
- data/lib/justgiving/client.rb +45 -6
- data/lib/justgiving/error.rb +7 -3
- data/lib/justgiving/event.rb +19 -0
- data/lib/justgiving/fundraising.rb +34 -0
- data/lib/justgiving/logger.rb +16 -0
- data/lib/justgiving/project.rb +11 -0
- data/lib/justgiving/search.rb +6 -2
- data/lib/justgiving/team.rb +19 -0
- data/lib/justgiving/version.rb +1 -1
- data/lib/justgiving.rb +5 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d29db277bc2f519dbed192ccea0c26abd46153d7
|
4
|
+
data.tar.gz: 9ad5a323bf3738a7bbe173b17fd25c6ed045cda5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56873c41ba229f00db3a0c9ca05d4d3f4e9544d1228a0de07bd150c80f45a6556566f42ff672bd7d0d0410186a239693d344ce063829fbda361359e5bc1f4279
|
7
|
+
data.tar.gz: 936c90d79879b719c5c35d1102cbc499b8dd31707470bbbcaf52ec4ff01218ad029931f58fd1b119af7bab4ba07334f2c4d228f50ad7fd11935502bbf8f6e565
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "client"
|
2
|
+
|
3
|
+
module JustGiving
|
4
|
+
class Account < Client
|
5
|
+
|
6
|
+
# Todo:
|
7
|
+
# RetrieveAccount
|
8
|
+
# AccountRegistration
|
9
|
+
# Validate
|
10
|
+
# GetFundraisingPagesForUser
|
11
|
+
# GetDonationsForUser
|
12
|
+
# AccountAvailabilityCheck
|
13
|
+
# ChangePassword
|
14
|
+
# RequestPasswordReminder
|
15
|
+
# GetUserContentRatingHistory
|
16
|
+
# RateContent
|
17
|
+
# GetContentFeed
|
18
|
+
# InterestsGet
|
19
|
+
# InterestsAdd
|
20
|
+
# InterestsReplace
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/justgiving/charity.rb
CHANGED
@@ -7,6 +7,10 @@ module JustGiving
|
|
7
7
|
get("charity/#{id}")
|
8
8
|
end
|
9
9
|
|
10
|
+
# def authenticate_charity_account(account_details = {})
|
11
|
+
# post("charity/authenticate", account_details)
|
12
|
+
# end
|
13
|
+
|
10
14
|
def get_events_by_charity_id(id)
|
11
15
|
get("charity/#{id}/events")
|
12
16
|
end
|
@@ -15,6 +19,12 @@ module JustGiving
|
|
15
19
|
get("charity/#{id}/donations")
|
16
20
|
end
|
17
21
|
|
22
|
+
# Todo
|
23
|
+
# CharityDeleteFundraisingPageAttribution
|
24
|
+
# CharityUpdateFundraisingPageAttribution
|
25
|
+
# CharityAppendToFundraisingPageAttribution
|
26
|
+
# CharityGetFundraisingPageAttribution
|
27
|
+
|
18
28
|
def get_charity_categories
|
19
29
|
get("charity/categories")
|
20
30
|
end
|
data/lib/justgiving/client.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
require "faraday"
|
2
2
|
require "faraday_middleware"
|
3
3
|
require_relative "error"
|
4
|
+
require_relative "logger"
|
4
5
|
|
5
6
|
module JustGiving
|
6
7
|
class Client
|
7
8
|
|
8
|
-
def initialize(token)
|
9
|
+
def initialize(token, environment=nil)
|
10
|
+
if environment.nil? || environment == :production
|
11
|
+
environment = :production
|
12
|
+
@base_url = "https://api.justgiving.com/#{@token}/v1/"
|
13
|
+
elsif environment == :staging
|
14
|
+
@base_url = "https://api-staging.justgiving.com/#{@token}/v1/"
|
15
|
+
elsif environment == :sandbox
|
16
|
+
@base_url = "https://api-sandbox.justgiving.com/#{@token}/v1/"
|
17
|
+
else
|
18
|
+
raise Error::InvalidEnvironment
|
19
|
+
end
|
20
|
+
|
9
21
|
@token = token
|
10
|
-
@
|
22
|
+
@environment = environment
|
11
23
|
@connection_defaults = {
|
12
24
|
url: @base_url,
|
13
25
|
headers: {
|
@@ -15,11 +27,15 @@ module JustGiving
|
|
15
27
|
'Content-Type' => 'application/json'
|
16
28
|
}
|
17
29
|
}
|
30
|
+
|
18
31
|
@connection = Faraday.new(@connection_defaults) do |connection|
|
32
|
+
connection.request :json
|
33
|
+
|
19
34
|
connection.response :json, :content_type => /\bjson$/
|
20
|
-
|
21
|
-
connection.
|
22
|
-
connection.use
|
35
|
+
|
36
|
+
connection.use Error::RaiseError
|
37
|
+
connection.use Logger
|
38
|
+
connection.adapter Faraday.default_adapter
|
23
39
|
end
|
24
40
|
end
|
25
41
|
|
@@ -28,10 +44,33 @@ module JustGiving
|
|
28
44
|
def get(path, query=nil)
|
29
45
|
response = @connection.get do |request|
|
30
46
|
request.url path
|
31
|
-
request.params.merge! query
|
47
|
+
request.params.merge! query unless query.nil?
|
48
|
+
end
|
49
|
+
response.body
|
50
|
+
end
|
51
|
+
|
52
|
+
def post(path, payload=nil)
|
53
|
+
response = @connection.post do |request|
|
54
|
+
request.url path
|
55
|
+
request.body = payload unless payload.nil?
|
32
56
|
end
|
33
57
|
response.body
|
34
58
|
end
|
35
59
|
|
60
|
+
def put(path, payload=nil)
|
61
|
+
response = @connection.put do |request|
|
62
|
+
request.url path
|
63
|
+
request.body = payload unless payload.nil?
|
64
|
+
end
|
65
|
+
response.body
|
66
|
+
end
|
67
|
+
|
68
|
+
def head(path)
|
69
|
+
response = @connection.head do |request|
|
70
|
+
request.url path
|
71
|
+
end
|
72
|
+
true # We expect Error::NoResults to be thrown if the query is unsuccessful
|
73
|
+
end
|
74
|
+
|
36
75
|
end
|
37
76
|
end
|
data/lib/justgiving/error.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module JustGiving
|
2
2
|
module Error
|
3
3
|
|
4
|
-
class
|
5
|
-
class
|
6
|
-
|
4
|
+
class ConfigurationError < StandardError; end
|
5
|
+
class InvalidEnvironment < ConfigurationError; end
|
6
|
+
|
7
|
+
class RequestError < StandardError; end
|
8
|
+
class BadRequest < RequestError; end
|
9
|
+
class NoResults < RequestError; end
|
10
|
+
class InternalServerError < RequestError; end
|
7
11
|
|
8
12
|
class RaiseError < Faraday::Response::Middleware
|
9
13
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "client"
|
2
|
+
|
3
|
+
module JustGiving
|
4
|
+
class Event < Client
|
5
|
+
|
6
|
+
def get_by_event_id(id)
|
7
|
+
get("event/#{id}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_pages_by_event_id(id, filters = {})
|
11
|
+
get("event/#{id}/pages")
|
12
|
+
end
|
13
|
+
|
14
|
+
# def register_event(payload = {})
|
15
|
+
# post("event", payload)
|
16
|
+
# end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "client"
|
2
|
+
|
3
|
+
module JustGiving
|
4
|
+
class Fundraising < Client
|
5
|
+
|
6
|
+
def check_if_page_exists_by_name(name)
|
7
|
+
head("fundraising/pages/#{name}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def suggest_page_short_names(preferred)
|
11
|
+
get("fundraising/pages/suggest", {'preferredName' => preferred})
|
12
|
+
end
|
13
|
+
|
14
|
+
# Todo:
|
15
|
+
# RegisterFundraisingPage
|
16
|
+
# GetFundraisingPageDetails
|
17
|
+
# GetFundraisingPages
|
18
|
+
# GetFundraisingPageDonations
|
19
|
+
# UpdateFundraisingPage
|
20
|
+
# PageUpdates
|
21
|
+
# PageUpdateById
|
22
|
+
# PageUpdatesAddPost
|
23
|
+
# DeleteFundraisingPageAttribution
|
24
|
+
# UpdateFundraisingPageAttribution
|
25
|
+
# AppendToFundraisingPageAttribution
|
26
|
+
# GetFundraisingPageAttribution
|
27
|
+
# UploadImage
|
28
|
+
# AddImageToFundraisingPage
|
29
|
+
# GetImagesForFundraisingPage
|
30
|
+
# AddVideoToFundraisingPage
|
31
|
+
# GetVideosForFundraisingPage
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "faraday"
|
2
|
+
|
3
|
+
module JustGiving
|
4
|
+
class Logger < Faraday::Middleware
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
puts "Request: #{env[:method].to_s.upcase} #{env[:url]}"
|
8
|
+
puts "Request body: #{env[:body]}" unless env[:body].nil?
|
9
|
+
|
10
|
+
@app.call(env).on_complete do
|
11
|
+
puts "Response: #{env[:status]} #{env[:body]}" unless env[:status] == 200
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/justgiving/search.rb
CHANGED
@@ -7,6 +7,10 @@ module JustGiving
|
|
7
7
|
get("charity/search", filters)
|
8
8
|
end
|
9
9
|
|
10
|
+
def search_commemorations(filters = {})
|
11
|
+
get("remember/search", filters)
|
12
|
+
end
|
13
|
+
|
10
14
|
def search_events(filters = {})
|
11
15
|
get("event/search", filters)
|
12
16
|
end
|
@@ -15,8 +19,8 @@ module JustGiving
|
|
15
19
|
get("fundraising/search", filters)
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
get("
|
22
|
+
def search_projects(filters = {})
|
23
|
+
get("project", filters)
|
20
24
|
end
|
21
25
|
|
22
26
|
def search_teams(filters = {})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "client"
|
2
|
+
|
3
|
+
module JustGiving
|
4
|
+
class Team < Client
|
5
|
+
|
6
|
+
def get_team_by_name(name)
|
7
|
+
get("team/#{name}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def check_if_team_exists_by_name(name)
|
11
|
+
head("team/#{name}")
|
12
|
+
end
|
13
|
+
|
14
|
+
# Todo:
|
15
|
+
# CreateOrUpdateTeam
|
16
|
+
# JoinTeam
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/justgiving/version.rb
CHANGED
data/lib/justgiving.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module JustGiving
|
2
2
|
|
3
3
|
# Clients
|
4
|
+
require_relative "justgiving/account"
|
4
5
|
require_relative "justgiving/charity"
|
5
6
|
require_relative "justgiving/country"
|
6
7
|
require_relative "justgiving/currency"
|
7
8
|
require_relative "justgiving/donation"
|
9
|
+
require_relative "justgiving/event"
|
10
|
+
require_relative "justgiving/fundraising"
|
11
|
+
require_relative "justgiving/project"
|
8
12
|
require_relative "justgiving/search"
|
13
|
+
require_relative "justgiving/team"
|
9
14
|
|
10
15
|
require_relative "justgiving/error"
|
11
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justgiving
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Dent
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,13 +80,19 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- justgiving.gemspec
|
82
82
|
- lib/justgiving.rb
|
83
|
+
- lib/justgiving/account.rb
|
83
84
|
- lib/justgiving/charity.rb
|
84
85
|
- lib/justgiving/client.rb
|
85
86
|
- lib/justgiving/country.rb
|
86
87
|
- lib/justgiving/currency.rb
|
87
88
|
- lib/justgiving/donation.rb
|
88
89
|
- lib/justgiving/error.rb
|
90
|
+
- lib/justgiving/event.rb
|
91
|
+
- lib/justgiving/fundraising.rb
|
92
|
+
- lib/justgiving/logger.rb
|
93
|
+
- lib/justgiving/project.rb
|
89
94
|
- lib/justgiving/search.rb
|
95
|
+
- lib/justgiving/team.rb
|
90
96
|
- lib/justgiving/version.rb
|
91
97
|
homepage: http://www.github.com/jackdent/justgiving
|
92
98
|
licenses:
|