heroix 0.2.1 → 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 +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/lib/heroix.rb +7 -60
- data/lib/heroix/client.rb +65 -0
- data/lib/heroix/resource.rb +14 -1
- data/lib/heroix/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6918e1258f70ff55500f20aa8bc3255b718a283
|
4
|
+
data.tar.gz: 7753d1b4968efe9cda393a115a099c9709de3653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b849ec9b037a4adb6407eae7bcb337e1f056c1584e204cfb628e3fc903ba60a9f8f0a699b7b7b9607eba1cf6ab6942f20bbd415d61a856ee56b6ee5a101f6fa
|
7
|
+
data.tar.gz: d57adf6700ba42c4c2fbc5a51282a4f9b282b43d108c59172af11f0f23a7a88cfcc9a1816a39e7f7c375786f83632844a8a8a7b45fdde9151b273ae652c441a0
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/heroix.rb
CHANGED
@@ -1,66 +1,13 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'heroix/version'
|
2
|
-
require 'heroix/
|
3
|
+
require 'heroix/client'
|
3
4
|
|
4
5
|
module Heroix
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def session
|
11
|
-
build_resource :session, :session
|
12
|
-
end
|
13
|
-
|
14
|
-
def organisations
|
15
|
-
build_resource :organisations, :organisation
|
16
|
-
end
|
17
|
-
|
18
|
-
def beneficiaries
|
19
|
-
build_resource :beneficiaries, :beneficiary
|
20
|
-
end
|
21
|
-
|
22
|
-
def beneficiary_registrations
|
23
|
-
build_resource :beneficiary_registrations, :beneficiary_registration
|
24
|
-
end
|
25
|
-
|
26
|
-
def beneficiary_rules
|
27
|
-
build_resource :beneficiary_rules, :beneficiary_rule
|
28
|
-
end
|
29
|
-
|
30
|
-
def campaigns
|
31
|
-
build_resource :campaigns, :campaign
|
32
|
-
end
|
33
|
-
|
34
|
-
def campaign_peer_to_peers
|
35
|
-
build_resource :campaign_peer_to_peers, :campaign_peer_to_peer
|
36
|
-
end
|
37
|
-
|
38
|
-
def organisation_beneficiaries
|
39
|
-
build_resource :organisation_beneficiaries, :organisation_beneficiary
|
40
|
-
end
|
41
|
-
|
42
|
-
def campaign_beneficiaries
|
43
|
-
build_resource :campaign_beneficiaries, :campaign_beneficiary
|
44
|
-
end
|
45
|
-
|
46
|
-
def microsites
|
47
|
-
build_resource :microsites, :microsite
|
48
|
-
end
|
49
|
-
|
50
|
-
def microsite_pages
|
51
|
-
build_resource :microsite_pages, :microsite_page
|
52
|
-
end
|
53
|
-
|
54
|
-
def search(type, params)
|
55
|
-
build_resource("search/#{type}", type).index(params).fetch(type, [])
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
6
|
+
def self.logger
|
7
|
+
@logger ||= Logger.new(STDOUT)
|
8
|
+
end
|
59
9
|
|
60
|
-
|
61
|
-
|
62
|
-
:token => token,
|
63
|
-
:type => type
|
64
|
-
end
|
10
|
+
def self.logger=(logger)
|
11
|
+
@logger = logger
|
65
12
|
end
|
66
13
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative 'resource'
|
2
|
+
|
3
|
+
module Heroix
|
4
|
+
class Client < Resource
|
5
|
+
def users
|
6
|
+
build_resource :users, :user
|
7
|
+
end
|
8
|
+
|
9
|
+
def session
|
10
|
+
build_resource :session, :session
|
11
|
+
end
|
12
|
+
|
13
|
+
def organisations
|
14
|
+
build_resource :organisations, :organisation
|
15
|
+
end
|
16
|
+
|
17
|
+
def beneficiaries
|
18
|
+
build_resource :beneficiaries, :beneficiary
|
19
|
+
end
|
20
|
+
|
21
|
+
def beneficiary_registrations
|
22
|
+
build_resource :beneficiary_registrations, :beneficiary_registration
|
23
|
+
end
|
24
|
+
|
25
|
+
def beneficiary_rules
|
26
|
+
build_resource :beneficiary_rules, :beneficiary_rule
|
27
|
+
end
|
28
|
+
|
29
|
+
def campaigns
|
30
|
+
build_resource :campaigns, :campaign
|
31
|
+
end
|
32
|
+
|
33
|
+
def campaign_peer_to_peers
|
34
|
+
build_resource :campaign_peer_to_peers, :campaign_peer_to_peer
|
35
|
+
end
|
36
|
+
|
37
|
+
def organisation_beneficiaries
|
38
|
+
build_resource :organisation_beneficiaries, :organisation_beneficiary
|
39
|
+
end
|
40
|
+
|
41
|
+
def campaign_beneficiaries
|
42
|
+
build_resource :campaign_beneficiaries, :campaign_beneficiary
|
43
|
+
end
|
44
|
+
|
45
|
+
def microsites
|
46
|
+
build_resource :microsites, :microsite
|
47
|
+
end
|
48
|
+
|
49
|
+
def microsite_pages
|
50
|
+
build_resource :microsite_pages, :microsite_page
|
51
|
+
end
|
52
|
+
|
53
|
+
def search(type, params)
|
54
|
+
build_resource("search/#{type}", type).index(params)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def build_resource(path, type)
|
60
|
+
Resource.new :url => url_for(path),
|
61
|
+
:token => token,
|
62
|
+
:type => type
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/heroix/resource.rb
CHANGED
@@ -47,6 +47,15 @@ module Heroix
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def request(method, url, options = {})
|
50
|
+
rest_logger = RestClient.log
|
51
|
+
RestClient.log = logger
|
52
|
+
|
53
|
+
perform_request(method, url, options)
|
54
|
+
ensure
|
55
|
+
RestClient.log = rest_logger
|
56
|
+
end
|
57
|
+
|
58
|
+
def perform_request(method, url, options)
|
50
59
|
handle RestClient::Request.execute(
|
51
60
|
:method => method,
|
52
61
|
:url => url,
|
@@ -60,7 +69,7 @@ module Heroix
|
|
60
69
|
|
61
70
|
def handle(response)
|
62
71
|
deprecation = response.headers[:x_deprecation]
|
63
|
-
|
72
|
+
logger.warn "[heroix] DEPRECATION WARNING #{deprecation}" if deprecation
|
64
73
|
|
65
74
|
parse_response response.to_str
|
66
75
|
end
|
@@ -74,5 +83,9 @@ module Heroix
|
|
74
83
|
data = { type => data } if data && type
|
75
84
|
data.to_json
|
76
85
|
end
|
86
|
+
|
87
|
+
def logger
|
88
|
+
Heroix.logger
|
89
|
+
end
|
77
90
|
end
|
78
91
|
end
|
data/lib/heroix/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leon Fu
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-01-
|
13
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- bin/ci
|
98
98
|
- heroix.gemspec
|
99
99
|
- lib/heroix.rb
|
100
|
+
- lib/heroix/client.rb
|
100
101
|
- lib/heroix/resource.rb
|
101
102
|
- lib/heroix/version.rb
|
102
103
|
- lib/jack_and_rose.rb
|