sqwiggle-ruby 0.1.0 → 0.1.1
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/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +61 -7
- data/lib/sqwiggle-ruby.rb +1 -0
- data/lib/sqwiggle/api.rb +12 -0
- data/lib/sqwiggle/api/client.rb +2 -6
- data/lib/sqwiggle/version.rb +1 -1
- data/sqwiggle-ruby.gemspec +0 -3
- metadata +3 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14b3945293f0642e0d9270fbd303850511aa4f02
|
4
|
+
data.tar.gz: c72b4b53e004bdd3c9fd27c1add24cedae67962a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5600af7ae02615d1b411d092611413f28fa2aabe8282f9a78a5e0eecdf119627606f2b5431f60da12d13d40a9c8c22edfb9207bc29bfa490c2a7bb9378076176
|
7
|
+
data.tar.gz: 6231e7c35e8228a53747f4243402d09416a400a61bb6c344d733ab6cf549bf029645379c95258d72ebd3de9e367b7f73c11cdf266fba6a8f4c71b78e24e012a9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,6 +4,7 @@ rvm:
|
|
4
4
|
- 1.9.2
|
5
5
|
- 1.9.3
|
6
6
|
- 2.0.0
|
7
|
+
- 2.1.0
|
7
8
|
- rbx
|
8
9
|
- ruby-head
|
9
10
|
matrix:
|
@@ -20,3 +21,7 @@ matrix:
|
|
20
21
|
- rvm: ruby-head
|
21
22
|
fast_finish: true
|
22
23
|
script: bundle exec rspec
|
24
|
+
notifications:
|
25
|
+
sqwiggle:
|
26
|
+
rooms:
|
27
|
+
- secure: GCzKzx6svwXQvRekfXojzgJsE7hJz4mb8PMy71d8AWyOYgEGAyKH9Ysb5pXQuMXlWo7esCegzci398FY9+zNzYl8RZxX4AR/uND2scaO8alp09/i6QCz/JdU8JZC5H9tSWPU6xCDAdbPb3XdEYYVZaj23Ckn7SqtYg/KngX5zs8=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# Ruby Client for the Sqwiggle API
|
2
2
|
|
3
|
-
The API and this gem are currently in ~~BETA~~ ALPHA
|
4
|
-
|
5
|
-
Comments, pull requests, discussion and input are all welcome at this stage.
|
6
|
-
|
7
3
|

|
8
4
|
|
9
|
-
A Ruby
|
5
|
+
A Ruby wrapper for the Sqwiggle REST API.
|
10
6
|
|
11
7
|
## Installation
|
12
8
|
|
@@ -22,13 +18,71 @@ Or install it yourself as:
|
|
22
18
|
|
23
19
|
$ gem install sqwiggle-ruby
|
24
20
|
|
25
|
-
##
|
21
|
+
## Configuration
|
26
22
|
|
27
23
|
Create an API Client at https://www.sqwiggle.com/company/clients
|
28
24
|
|
25
|
+
Once you have a token there are two ways of instantiating an instance of a client.
|
26
|
+
|
27
|
+
### Globally (not thread safe)
|
28
|
+
```ruby
|
29
|
+
Sqwiggle.token = 'your token here'
|
30
|
+
client = Sqwiggle.client
|
31
|
+
```
|
32
|
+
### Locally (thread safe)
|
33
|
+
```ruby
|
34
|
+
client = Sqwiggle.client('your token here')
|
35
|
+
```
|
36
|
+
Which is basically syntactic sugar for
|
37
|
+
```ruby
|
38
|
+
Sqwiggle::Api::Client.new('your token here')
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
### Services
|
44
|
+
|
45
|
+
A service acts a bit like an ActiveRecord relation proxy
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
#load the message service
|
49
|
+
messages = client.messages
|
50
|
+
|
51
|
+
#the service currently has the following methods
|
52
|
+
old_message = messages.find 42
|
53
|
+
new_message = messages.new(params)
|
54
|
+
all_messages = messages.all
|
55
|
+
```
|
56
|
+
|
57
|
+
#### Available Services
|
58
|
+
* messages
|
59
|
+
* invites
|
60
|
+
* conversations
|
61
|
+
* attachments
|
62
|
+
* organizations
|
63
|
+
* rooms
|
64
|
+
* users
|
65
|
+
|
66
|
+
### Resources
|
67
|
+
Resources are not dissimilar to an ActiveResource or an ActiveRecord object
|
68
|
+
```ruby
|
69
|
+
#with a persisted object
|
70
|
+
message = client.messages.find 42
|
71
|
+
message.update(text:'the message') #fails silently
|
72
|
+
message.update!(text:'the message') #raises a Sqwiggle::Api::Errors::BadRequestError
|
73
|
+
|
74
|
+
#creating a new object
|
75
|
+
message = client.messages.new
|
76
|
+
message.text = 'the new message'
|
77
|
+
message.save #fails silently
|
78
|
+
message.save! #raises an error
|
79
|
+
```
|
80
|
+
|
29
81
|
## TODO
|
30
82
|
|
31
|
-
*
|
83
|
+
* Capistrano integration
|
84
|
+
* Pagination
|
85
|
+
* Rdoc (or similar)
|
32
86
|
|
33
87
|
|
34
88
|
## Contributing
|
data/lib/sqwiggle-ruby.rb
CHANGED
data/lib/sqwiggle/api.rb
ADDED
data/lib/sqwiggle/api/client.rb
CHANGED
@@ -4,7 +4,6 @@ module Sqwiggle
|
|
4
4
|
class NoTokenError < StandardError;end;
|
5
5
|
|
6
6
|
attr_accessor :token
|
7
|
-
attr_writer :url #for testing purposes
|
8
7
|
|
9
8
|
def initialize(token=nil)
|
10
9
|
unless @token = token || Sqwiggle.token
|
@@ -54,15 +53,12 @@ module Sqwiggle
|
|
54
53
|
|
55
54
|
private
|
56
55
|
|
57
|
-
def url
|
58
|
-
@url || 'https://api.sqwiggle.com/'
|
59
|
-
end
|
60
|
-
|
61
56
|
def connection
|
62
|
-
@connection ||= Faraday.new(url:url) do |f|
|
57
|
+
@connection ||= Faraday.new(url:Sqwiggle::Api.url) do |f|
|
63
58
|
f.request :url_encoded # form-encode POST params
|
64
59
|
f.adapter Faraday.default_adapter # make requests with Net::HTTP
|
65
60
|
f.basic_auth token, 'X'
|
61
|
+
f.headers['User-Agent'] = "sqwiggle-ruby #{Sqwiggle::VERSION}"
|
66
62
|
f.use ErrorHandler
|
67
63
|
end
|
68
64
|
end
|
data/lib/sqwiggle/version.rb
CHANGED
data/sqwiggle-ruby.gemspec
CHANGED
@@ -24,7 +24,4 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
26
26
|
spec.add_development_dependency "pry"
|
27
|
-
spec.add_development_dependency 'rspec'
|
28
|
-
spec.add_development_dependency 'webmock'
|
29
|
-
spec.add_development_dependency 'fuubar'
|
30
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqwiggle-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,48 +80,6 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
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
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: fuubar
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - '>='
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
83
|
description: Ruby wrapper for the sqwiggle API
|
126
84
|
email:
|
127
85
|
- luke@sqwiggle.com
|
@@ -137,6 +95,7 @@ files:
|
|
137
95
|
- README.md
|
138
96
|
- Rakefile
|
139
97
|
- lib/sqwiggle-ruby.rb
|
98
|
+
- lib/sqwiggle/api.rb
|
140
99
|
- lib/sqwiggle/api/client.rb
|
141
100
|
- lib/sqwiggle/api/error_handler.rb
|
142
101
|
- lib/sqwiggle/api/errors/authentication_error.rb
|