quip 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/circle.yml +3 -0
- data/lib/quip.rb +5 -0
- data/lib/quip/client.rb +38 -0
- data/lib/quip/version.rb +3 -0
- data/quip.gemspec +28 -0
- data/spec/quip_client_spec.rb +47 -0
- data/spec/spec_helper.rb +19 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c266130af9bc106c943d5b7f6463facaec8ddede
|
4
|
+
data.tar.gz: fe8882697ca393c219c9f3ad4af2354d44372153
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c78b5849a800ebb4d400e8b60e43e8f96f4459bf7ec65e44ff86231270b08862e54a7689f992c96e35c2ba92af6bb13b6308f69cca3a9abb2ef1f32d53e8f14
|
7
|
+
data.tar.gz: 90422fb009ed4da121b3d46111e574e6f53f1973c66ede924d061dd0baf4264c7804c312143dbd5586dd387599f1d3a6a6b1c0c9f84ee8b65f4ae8d0c3e8f002
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 jacamat
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Quip API Ruby Client
|
2
|
+
|
3
|
+
This is the unofficial Quip API Ruby client library.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'quip'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install quip
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
client = Quip::QuipClient(access_token: '...')
|
23
|
+
user = client.get_authenticated_user()
|
24
|
+
desktop = client.get_folder(user['desktop_folder_id'])
|
25
|
+
puts "There are #{desktop['children'].length} items on the desktop"
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( http://github.com/jacamat/quip-ruby/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/circle.yml
ADDED
data/lib/quip.rb
ADDED
data/lib/quip/client.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'unirest'
|
2
|
+
|
3
|
+
module Quip
|
4
|
+
class QuipClient
|
5
|
+
attr_reader :access_token, :client_id, :client_secret,
|
6
|
+
:base_url, :request_timeout
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@access_token = options.fetch(:access_token)
|
10
|
+
@client_id = options.fetch(:client_id, nil)
|
11
|
+
@client_secret = options.fetch(:client_secret, nil)
|
12
|
+
@base_url = options.fetch(:base_url, 'https://platform.quip.com')
|
13
|
+
@request_timeout = options.fetch(:request_timeout, 10)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_authenticated_user
|
17
|
+
get_json('users/current')
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_folder(folder_id)
|
21
|
+
get_json("folders/#{folder_id}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_thread(thread_id)
|
25
|
+
get_json("threads/#{thread_id}")
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def get_json(path)
|
31
|
+
response = Unirest.get("#{base_url}/1/#{path}", headers: {
|
32
|
+
'Authorization' => "Bearer #{access_token}"
|
33
|
+
})
|
34
|
+
|
35
|
+
response.body
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/quip/version.rb
ADDED
data/quip.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quip/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'quip'
|
8
|
+
spec.version = Quip::VERSION
|
9
|
+
spec.authors = ['jacqueline matuszak']
|
10
|
+
spec.email = ['j@jacamat.com']
|
11
|
+
spec.summary = %q(This is the unofficial Quip API Ruby client library.)
|
12
|
+
spec.homepage = 'https://github.com/jacamat/quip-ruby'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'unirest'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'pry'
|
24
|
+
spec.add_development_dependency 'pry-nav'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'webmock'
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quip'
|
3
|
+
|
4
|
+
describe Quip::QuipClient do
|
5
|
+
specify '#initialize' do
|
6
|
+
client = Quip::QuipClient.new(
|
7
|
+
access_token: '1234',
|
8
|
+
client_id: 1,
|
9
|
+
client_secret: 'secret',
|
10
|
+
base_url: 'http://example.com',
|
11
|
+
request_timeout: 30)
|
12
|
+
|
13
|
+
expect(client.access_token).to eq('1234')
|
14
|
+
expect(client.client_id).to eq(1)
|
15
|
+
expect(client.client_secret).to eq('secret')
|
16
|
+
expect(client.base_url).to eq('http://example.com')
|
17
|
+
expect(client.request_timeout).to eq(30)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'authenticated client' do
|
21
|
+
let(:client) { Quip::QuipClient.new(access_token: 'example') }
|
22
|
+
|
23
|
+
specify '#get_authenticated_user' do
|
24
|
+
stub_request(:get, 'https://platform.quip.com/1/users/current')
|
25
|
+
.to_return(body: '{"name": "Joffrey Baratheon"}')
|
26
|
+
|
27
|
+
user = client.get_authenticated_user()
|
28
|
+
expect(user['name']).to eq('Joffrey Baratheon')
|
29
|
+
end
|
30
|
+
|
31
|
+
specify '#get_folder' do
|
32
|
+
stub_request(:get, 'https://platform.quip.com/1/folders/ZYbAOAbHPyR')
|
33
|
+
.to_return(body: '{"folder":{"title": "The true king of Westeros"}}')
|
34
|
+
|
35
|
+
desktop = client.get_folder('ZYbAOAbHPyR')
|
36
|
+
expect(desktop['folder']['title']).to eq('The true king of Westeros')
|
37
|
+
end
|
38
|
+
|
39
|
+
specify '#get_thread' do
|
40
|
+
stub_request(:get, 'https://platform.quip.com/1/threads/YeXAAA2Uwb3')
|
41
|
+
.to_return(body: '{"html": "<h1>Valor Morghulis</h1>"}')
|
42
|
+
|
43
|
+
thread = client.get_thread('YeXAAA2Uwb3')
|
44
|
+
expect(thread['html']).to eq('<h1>Valor Morghulis</h1>')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
6
|
+
# loaded once.
|
7
|
+
#
|
8
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
|
14
|
+
# Run specs in random order to surface order dependencies. If you find an
|
15
|
+
# order dependency and want to debug it, you can fix the order by providing
|
16
|
+
# the seed, which is printed after each run.
|
17
|
+
# --seed 1234
|
18
|
+
config.order = 'random'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jacqueline matuszak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unirest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-nav
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- j@jacamat.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- circle.yml
|
125
|
+
- lib/quip.rb
|
126
|
+
- lib/quip/client.rb
|
127
|
+
- lib/quip/version.rb
|
128
|
+
- quip.gemspec
|
129
|
+
- spec/quip_client_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: https://github.com/jacamat/quip-ruby
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.2.2
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: This is the unofficial Quip API Ruby client library.
|
155
|
+
test_files:
|
156
|
+
- spec/quip_client_spec.rb
|
157
|
+
- spec/spec_helper.rb
|