api_client 0.5.24 → 0.5.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/LICENSE +1 -1
- data/README.md +8 -2
- data/lib/api_client/version.rb +1 -1
- metadata +4 -15
- data/.gitignore +0 -9
- data/.rspec +0 -1
- data/.travis.yml +0 -13
- data/api_client.gemspec +0 -49
- data/examples/digg.rb +0 -31
- data/examples/flickr.rb +0 -37
- data/examples/github.rb +0 -52
- data/examples/highrise.rb +0 -41
- data/examples/twitter.rb +0 -34
- data/examples/twitter_oauth.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c28ef0d16bb54dd8665be3a02147117c944034782c1d538697d0c5a800d81d30
|
4
|
+
data.tar.gz: a46f810dacebf1933b96ba9e844075a95ccb57202ca9554be1ab135812dda52b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e992f5cd23729c1d3eb2cd290cc29b4ebb301799b6ce12740f347b831d09750759638f2bb4fb92db7530b1268d1e0a6b91e863681a2daacba67101ea1fa902d9
|
7
|
+
data.tar.gz: 1da3c79a1babc2dfe18a45e17e90b449d4984d829c0d0da444e69623cd2ec199c7b5f0adcf628750d3545d67aa4862f5c8ad3f370d9c8308bff45631e3b2f672
|
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright 2011 Zendesk
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ApiClient
|
1
|
+
ApiClient ![Tests](https://github.com/zendesk/api_client/workflows/Tests/badge.svg)
|
2
2
|
=========
|
3
3
|
|
4
4
|
ApiClient is an experimental builder for HTTP API clients. The goal is to provide a easy to use engine for constructing queries and map the responses to instances of Hashie::Mash subclasses.
|
@@ -154,8 +154,14 @@ ApiClient.logger.level = Logger::INFO
|
|
154
154
|
|
155
155
|
```
|
156
156
|
|
157
|
+
## Releasing new version of gem
|
158
|
+
|
159
|
+
1. Update version in [lib/api_client/version.rb](lib/api_client/version.rb) and push to `master`
|
160
|
+
2. Create new GitHub release with tag name starting with `v` and the version, for example `v1.0.0`
|
161
|
+
3. Gem will be automatically built and pushed to rubygems.org with GitHub Action
|
162
|
+
|
157
163
|
## Copyright and license
|
158
164
|
|
159
|
-
Copyright
|
165
|
+
Copyright 2011 Zendesk
|
160
166
|
|
161
167
|
Licensed under the [Apache License, Version 2.0](LICENSE)
|
data/lib/api_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zendesk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -93,22 +93,12 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
-
- ".gitignore"
|
97
|
-
- ".rspec"
|
98
|
-
- ".travis.yml"
|
99
96
|
- CHANGELOG.md
|
100
97
|
- Gemfile
|
101
98
|
- LICENSE
|
102
99
|
- Makefile
|
103
100
|
- README.md
|
104
101
|
- Rakefile
|
105
|
-
- api_client.gemspec
|
106
|
-
- examples/digg.rb
|
107
|
-
- examples/flickr.rb
|
108
|
-
- examples/github.rb
|
109
|
-
- examples/highrise.rb
|
110
|
-
- examples/twitter.rb
|
111
|
-
- examples/twitter_oauth.rb
|
112
102
|
- lib/api_client.rb
|
113
103
|
- lib/api_client/base.rb
|
114
104
|
- lib/api_client/connection/abstract.rb
|
@@ -164,15 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
154
|
requirements:
|
165
155
|
- - ">="
|
166
156
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
157
|
+
version: 2.2.0
|
168
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
159
|
requirements:
|
170
160
|
- - ">="
|
171
161
|
- !ruby/object:Gem::Version
|
172
162
|
version: '0'
|
173
163
|
requirements: []
|
174
|
-
|
175
|
-
rubygems_version: 2.5.2.3
|
164
|
+
rubygems_version: 3.2.0.pre1
|
176
165
|
signing_key:
|
177
166
|
specification_version: 3
|
178
167
|
summary: API client builder
|
data/.gitignore
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.travis.yml
DELETED
data/api_client.gemspec
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "api_client/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "api_client"
|
7
|
-
s.version = ApiClient::VERSION
|
8
|
-
s.authors = ["Zendesk"]
|
9
|
-
s.email = ["opensource@zendesk.com"]
|
10
|
-
s.homepage = "https://github.com/futuresimple/api_client"
|
11
|
-
s.summary = %q{API client builder}
|
12
|
-
s.description = %q{API client builder}
|
13
|
-
s.license = "Apache License Version 2.0"
|
14
|
-
|
15
|
-
s.rubyforge_project = "api_client"
|
16
|
-
|
17
|
-
# Declare runtime dependencies here:
|
18
|
-
def s.add_runtime_dependencies(method)
|
19
|
-
if RUBY_PLATFORM == "java"
|
20
|
-
send method, 'jrjackson'
|
21
|
-
else
|
22
|
-
send method, 'yajl-ruby'
|
23
|
-
end
|
24
|
-
|
25
|
-
send method, 'hashie', [">= 2.0.5"]
|
26
|
-
send method, 'faraday', [">= 0.8.1", "< 1.0.0"]
|
27
|
-
send method, 'multi_json', [">= 1.6.1"]
|
28
|
-
end
|
29
|
-
|
30
|
-
# Declare development dependencies here:
|
31
|
-
s.add_development_dependency 'rspec', '2.14.1'
|
32
|
-
|
33
|
-
if s.respond_to? :specification_version then
|
34
|
-
s.specification_version = 3
|
35
|
-
|
36
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
-
s.add_runtime_dependencies(:add_runtime_dependency)
|
38
|
-
else
|
39
|
-
s.add_runtime_dependencies(:add_dependency)
|
40
|
-
end
|
41
|
-
else
|
42
|
-
s.add_runtime_dependencies(:add_dependency)
|
43
|
-
end
|
44
|
-
|
45
|
-
s.files = `git ls-files`.split("\n")
|
46
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
47
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
48
|
-
s.require_paths = ["lib"]
|
49
|
-
end
|
data/examples/digg.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "api_client"
|
4
|
-
|
5
|
-
module Digg
|
6
|
-
|
7
|
-
class Base < ApiClient::Base
|
8
|
-
|
9
|
-
always do
|
10
|
-
endpoint "http://services.digg.com"
|
11
|
-
params :type => 'json'
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
class Collection < Base
|
17
|
-
|
18
|
-
def self.diggs
|
19
|
-
Digg.build get('/2.0/digg.getAll')['diggs']
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
class Digg < Base
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
Digg::Collection.diggs.each do |digg|
|
30
|
-
puts "#{digg.user.name}: #{digg.item.title}"
|
31
|
-
end
|
data/examples/flickr.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "./examples/config" if File.exists?('examples/config.rb')
|
4
|
-
require "api_client"
|
5
|
-
|
6
|
-
module Flickr
|
7
|
-
|
8
|
-
class Base < ApiClient::Base
|
9
|
-
always do
|
10
|
-
endpoint "http://api.flickr.com"
|
11
|
-
params :api_key => FLICKR_API_KEY,
|
12
|
-
:format => 'json',
|
13
|
-
:nojsoncallback => 1
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Collection < Base
|
18
|
-
|
19
|
-
def self.interesting
|
20
|
-
build params(:method => 'flickr.interestingness.getList').
|
21
|
-
get("/services/rest")
|
22
|
-
end
|
23
|
-
|
24
|
-
def photos
|
25
|
-
Photo.build self['photos']['photo']
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
class Photo < Base
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
Flickr::Collection.interesting.photos.each do |photo|
|
36
|
-
puts photo.title
|
37
|
-
end
|
data/examples/github.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "./examples/config" if File.exists?('examples/config.rb')
|
4
|
-
require "api_client"
|
5
|
-
require "time"
|
6
|
-
|
7
|
-
module Github
|
8
|
-
|
9
|
-
class Base < ApiClient::Base
|
10
|
-
namespace false
|
11
|
-
|
12
|
-
always do
|
13
|
-
endpoint "https://api.github.com"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class User < Base
|
18
|
-
|
19
|
-
def self.find(name)
|
20
|
-
fetch("/users/#{name}")
|
21
|
-
end
|
22
|
-
|
23
|
-
def events
|
24
|
-
Github::Event.fetch("/users/#{login}/events")
|
25
|
-
end
|
26
|
-
|
27
|
-
def received_events
|
28
|
-
Github::Event.fetch("/users/#{login}/received_events")
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
class Event < Base
|
34
|
-
|
35
|
-
def created_at
|
36
|
-
Time.parse self['created_at']
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
user = Github::User.find("marcinbunsch")
|
44
|
-
|
45
|
-
user.events.each do |event|
|
46
|
-
case event.type
|
47
|
-
when "FollowEvent"
|
48
|
-
puts "#{event.created_at} #{event.payload.target.login}: #{event.type}"
|
49
|
-
else
|
50
|
-
puts "#{event.created_at} #{event.repo.name} : #{event.type}"
|
51
|
-
end
|
52
|
-
end
|
data/examples/highrise.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "./examples/config" if File.exists?('examples/config.rb')
|
4
|
-
require "api_client"
|
5
|
-
require "multi_xml"
|
6
|
-
|
7
|
-
module Highrise
|
8
|
-
|
9
|
-
class Base < ApiClient::Resource::Base
|
10
|
-
format :xml
|
11
|
-
|
12
|
-
# In this hook we set the basic auth provided in the options
|
13
|
-
connection do |connection|
|
14
|
-
connection.handler.basic_auth connection.options[:user], connection.options[:pass]
|
15
|
-
end
|
16
|
-
|
17
|
-
always do
|
18
|
-
endpoint HIGHRISE_URL
|
19
|
-
options(:user => HIGHRISE_TOKEN, :pass => 'X')
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
class Person < Base
|
25
|
-
namespace false
|
26
|
-
|
27
|
-
always do
|
28
|
-
path "people"
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.build_one(hash)
|
32
|
-
hash.has_key?('people') ? build_many(hash['people']) : super(hash)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
Highrise::Person.find_all.each do |person|
|
40
|
-
puts "#{person.first_name} #{person.last_name}"
|
41
|
-
end
|
data/examples/twitter.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "api_client"
|
4
|
-
|
5
|
-
module Twitter
|
6
|
-
|
7
|
-
class Base < ApiClient::Base
|
8
|
-
always do
|
9
|
-
endpoint "http://api.twitter.com/"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Tweet < Base
|
14
|
-
end
|
15
|
-
|
16
|
-
class User < Base
|
17
|
-
|
18
|
-
def self.find_by_username(name)
|
19
|
-
params(:screen_name => name).fetch("/1/users/show.json")
|
20
|
-
end
|
21
|
-
|
22
|
-
def tweets
|
23
|
-
Tweet.params(:screen_name => self.screen_name).fetch("/1/statuses/user_timeline.json")
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
user = Twitter::User.find_by_username("marcinbunsch")
|
31
|
-
puts user.name
|
32
|
-
user.tweets.each do |tweet|
|
33
|
-
puts " #{tweet.text}"
|
34
|
-
end
|
data/examples/twitter_oauth.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "./examples/config" if File.exists?('examples/config.rb')
|
4
|
-
require "api_client"
|
5
|
-
|
6
|
-
module TwitterOauth
|
7
|
-
|
8
|
-
class Base < ApiClient::Base
|
9
|
-
|
10
|
-
always do
|
11
|
-
endpoint "https://api.twitter.com/"
|
12
|
-
adapter :oauth
|
13
|
-
|
14
|
-
options :oauth => {
|
15
|
-
:consumer_key => TWITTER_CONSUMER_KEY, :consumer_secret => TWITTER_CONSUMER_SECRET
|
16
|
-
}
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class Tweet < Base
|
23
|
-
|
24
|
-
def self.tweet(message)
|
25
|
-
build post('/1/statuses/update.json', :status => message)
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
config = { :token => TWITTER_TOKEN, :token_secret => TWITTER_SECRET }
|
33
|
-
|
34
|
-
message = TwitterOauth::Tweet.options(:oauth => config).tweet("test #{Time.now.to_i}")
|
35
|
-
|
36
|
-
puts message.text
|