gratitude 0.0.7 → 0.0.8
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/CHANGELOG.md +4 -0
- data/README.md +30 -3
- data/api_key.png +0 -0
- data/lib/gratitude/client.rb +16 -0
- data/lib/gratitude/tips.rb +19 -0
- data/lib/gratitude/version.rb +1 -1
- data/lib/gratitude.rb +3 -2
- data/spec/cassettes/tips.json +1 -0
- data/spec/gratitude/client_spec.rb +29 -0
- data/spec/gratitude/tips_spec.rb +53 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f98788dbd6abb9015c3714caf00069350d02015f
|
4
|
+
data.tar.gz: 321b4733b5987a3f46fe0f51b9efee0a0f242d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba9b54097f32bcd2e898a19e97d7a2ddd3d5c576b8842777d42efbdd48dd62567d8043757ddeb5d31ac321f7533777736d4a75397c5e3f290d2ba93a9bee5a21
|
7
|
+
data.tar.gz: 175a691394abc0682d316ffd86e1aaab09c7ce12cf4fcf3aec96311963c781f684bf951fdb62bf1d8c6f1393bdc088e86a6791551cb79e6d87893dcb3a3df0fb
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
### 0.1.0 (Upcoming Stable Release)
|
2
2
|
* Implement all aspects of the Gittip API.
|
3
3
|
|
4
|
+
### 0.0.7 (10/13/2013)
|
5
|
+
* Update documentation.
|
6
|
+
* Alias new to current in Statistics class.
|
7
|
+
|
4
8
|
### 0.0.6 (9/19/2013)
|
5
9
|
* Complete Gittip's Statistics API integration.
|
6
10
|
* Add more aliases and improve method clarity to signify method intent.
|
data/README.md
CHANGED
@@ -149,11 +149,38 @@ The above will retrieve the public profile of the above user. You can then acces
|
|
149
149
|
|
150
150
|
**TODO:** Implement the `my_tip` method into the Profile section once client authentication is finished.
|
151
151
|
|
152
|
-
##Tips
|
153
|
-
|
152
|
+
##Tips ([client authentication source code](https://github.com/JohnKellyFerguson/gratitude/blob/master/lib/gratitude/client.rb), [tips source code](https://github.com/JohnKellyFerguson/gratitude/blob/master/lib/gratitude/tips.rb))
|
153
|
+
The Tips aspect of the Gittip API allows you to retrieve the current tips of a user. In order to get this information, you will need your username and API_KEY. To find out your API Key, log into your Gittip account, go to your profile and at the bottom of the page you will find your API_KEY.
|
154
154
|
|
155
|
+

|
155
156
|
|
156
|
-
|
157
|
+
Now that you have your API_KEY, you can find out your current tips using Gratitude.
|
158
|
+
|
159
|
+
```
|
160
|
+
# First establish a connection to the Gittip API by passing in your credentials to Gratitude::Client.new
|
161
|
+
# You will need to pass in your username and api key like so.
|
162
|
+
client = Gratitude::Client.new(:username => "my_username", :api_key => "my_api_key")
|
163
|
+
# Then, to find out your current tips, simply call the current_tips method.
|
164
|
+
client.current_tips
|
165
|
+
```
|
166
|
+
This will will return an array of hashes that represent your current tips and will look similar to the following.
|
167
|
+
|
168
|
+
|
169
|
+
[
|
170
|
+
{"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
|
171
|
+
{"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"},
|
172
|
+
…
|
173
|
+
]
|
174
|
+
|
175
|
+
Please be aware that all of the amounts in the hash are strings and not floats.
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
* **TODO:** Add the ability to post and update tips to Gittip's API.
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
### Copyright and License
|
157
184
|
|
158
185
|
Copyright John Kelly Ferguson and Contributors, 2013
|
159
186
|
|
data/api_key.png
ADDED
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "gratitude/tips"
|
2
|
+
|
3
|
+
module Gratitude
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
include Gratitude::Client::Tips
|
7
|
+
|
8
|
+
attr_reader :username, :api_key
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@username = options[:username]
|
12
|
+
@api_key = options[:api_key]
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Payday
|
16
|
+
end # Gratitude
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gratitude
|
2
|
+
class Client
|
3
|
+
module Tips
|
4
|
+
|
5
|
+
def tips_url
|
6
|
+
"https://www.gittip.com/#{username}/tips.json"
|
7
|
+
end
|
8
|
+
|
9
|
+
def authorization
|
10
|
+
{ :basic_auth => { :username => api_key } }
|
11
|
+
end
|
12
|
+
|
13
|
+
def current_tips
|
14
|
+
self.class.get(tips_url, authorization).parsed_response
|
15
|
+
end
|
16
|
+
|
17
|
+
end # Tips
|
18
|
+
end # Client
|
19
|
+
end # Gratitude
|
data/lib/gratitude/version.rb
CHANGED
data/lib/gratitude.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require "httparty"
|
2
2
|
|
3
|
-
|
3
|
+
require "gratitude/client"
|
4
4
|
require "gratitude/payday"
|
5
5
|
require "gratitude/profile"
|
6
6
|
require "gratitude/statistics"
|
7
|
+
require "gratitude/tips"
|
7
8
|
require "gratitude/version"
|
8
9
|
|
10
|
+
|
9
11
|
module Gratitude
|
10
|
-
# Your code goes here...
|
11
12
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://5962b93a-5bf7-4cb6-ae6f-aa4114c5e4f2:@www.gittip.com/gratitude_test/tips.json","body":{"encoding":"US-ASCII","string":""},"headers":{}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Content-Type":["application/json"],"Date":["Tue, 15 Oct 2013 19:26:37 GMT"],"Expires":["Thu, 01 Jan 1970 00:00:00 GMT"],"Server":["Aspen! Cheroot!"],"Set-Cookie":["csrf_token=nuo6OY6TglUcv9JyVD316bT5VDsTywEL; expires=Tue, 14 Oct 2014 19:26:37 GMT; Path=/","session=c08eaad1dae3407c9d31f5ca904364bd; expires=Tue, 22 Oct 2013 19:26:36 GMT; httponly; Path=/; secure"],"Vary":["Cookie"],"X-Frame-Options":["SAMEORIGIN"],"X-Gittip-Version":["10.1.33"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"[\n {\n \"amount\": \"1.00\",\n \"platform\": \"gittip\",\n \"username\": \"whit537\"\n },\n {\n \"amount\": \"0.25\",\n \"platform\": \"gittip\",\n \"username\": \"JohnKellyFerguson\"\n }\n]"},"http_version":null},"recorded_at":"Tue, 15 Oct 2013 19:26:37 GMT"}],"recorded_with":"VCR 2.5.0"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Gratitude::Client do
|
4
|
+
|
5
|
+
describe "default attributes" do
|
6
|
+
|
7
|
+
it "should include httparty methods" do
|
8
|
+
Gratitude::Client.should include(HTTParty)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include tips methods" do
|
12
|
+
Gratitude::Client.should include(Gratitude::Client::Tips)
|
13
|
+
end
|
14
|
+
|
15
|
+
end # default attributes
|
16
|
+
|
17
|
+
describe "initialization" do
|
18
|
+
let(:username) { "JohnKellyFerguson"}
|
19
|
+
let(:api_key) { "this_is_an_api_key"}
|
20
|
+
|
21
|
+
subject { Gratitude::Client.new(:username => username, :api_key => api_key) }
|
22
|
+
|
23
|
+
its(:username) { should == username }
|
24
|
+
its(:api_key) { should == api_key }
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Gratitude::Client::Tips do
|
4
|
+
|
5
|
+
let(:username) { "gratitude_test" }
|
6
|
+
let(:api_key) { "5962b93a-5bf7-4cb6-ae6f-aa4114c5e4f2" }
|
7
|
+
|
8
|
+
let(:client) { Gratitude::Client.new(:username => username, :api_key => api_key) }
|
9
|
+
|
10
|
+
describe "#tips_url" do
|
11
|
+
it "returns the correct tips_url" do
|
12
|
+
expect(client.tips_url).to eq("https://www.gittip.com/gratitude_test/tips.json")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#authorization" do
|
17
|
+
it "returns the correct authorization hash" do
|
18
|
+
expect(client.authorization).to eq({ :basic_auth => { :username => api_key } })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
describe "authentication and api requests" do
|
24
|
+
|
25
|
+
let(:current_tips) { [{"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
|
26
|
+
{"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}] }
|
27
|
+
|
28
|
+
before do
|
29
|
+
VCR.insert_cassette "tips"
|
30
|
+
end
|
31
|
+
|
32
|
+
after do
|
33
|
+
VCR.eject_cassette
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#current_tips" do
|
37
|
+
it "returns the correct array of current tips" do
|
38
|
+
expect(client.current_tips).to eq (current_tips)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#update_tip" do
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#update_tips" do
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#update_tips_and_prune" do
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end # authentication and api requests
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gratitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Kelly Ferguson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -67,20 +67,26 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
+
- api_key.png
|
70
71
|
- gratitude.gemspec
|
71
72
|
- lib/gratitude.rb
|
73
|
+
- lib/gratitude/client.rb
|
72
74
|
- lib/gratitude/payday.rb
|
73
75
|
- lib/gratitude/profile.rb
|
74
76
|
- lib/gratitude/statistics.rb
|
77
|
+
- lib/gratitude/tips.rb
|
75
78
|
- lib/gratitude/version.rb
|
76
79
|
- spec/cassettes/complete_profile.json
|
77
80
|
- spec/cassettes/goal_profile.json
|
78
81
|
- spec/cassettes/incomplete_profile.json
|
79
82
|
- spec/cassettes/paydays.json
|
80
83
|
- spec/cassettes/statistics.json
|
84
|
+
- spec/cassettes/tips.json
|
85
|
+
- spec/gratitude/client_spec.rb
|
81
86
|
- spec/gratitude/payday_spec.rb
|
82
87
|
- spec/gratitude/profile_spec.rb
|
83
88
|
- spec/gratitude/statistics_spec.rb
|
89
|
+
- spec/gratitude/tips_spec.rb
|
84
90
|
- spec/gratitude/version_spec.rb
|
85
91
|
- spec/spec_helper.rb
|
86
92
|
homepage: https://github.com/JohnKellyFerguson/gratitude
|
@@ -113,8 +119,11 @@ test_files:
|
|
113
119
|
- spec/cassettes/incomplete_profile.json
|
114
120
|
- spec/cassettes/paydays.json
|
115
121
|
- spec/cassettes/statistics.json
|
122
|
+
- spec/cassettes/tips.json
|
123
|
+
- spec/gratitude/client_spec.rb
|
116
124
|
- spec/gratitude/payday_spec.rb
|
117
125
|
- spec/gratitude/profile_spec.rb
|
118
126
|
- spec/gratitude/statistics_spec.rb
|
127
|
+
- spec/gratitude/tips_spec.rb
|
119
128
|
- spec/gratitude/version_spec.rb
|
120
129
|
- spec/spec_helper.rb
|