taskworld 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/.travis.yml +1 -0
- data/README.md +16 -20
- data/lib/taskworld/client.rb +41 -0
- data/lib/taskworld/config.rb +22 -0
- data/lib/taskworld/connection.rb +24 -0
- data/lib/taskworld/endpoints/project.rb +9 -0
- data/lib/taskworld/endpoints/task.rb +9 -0
- data/lib/taskworld/endpoints/tasklist.rb +9 -0
- data/lib/taskworld/endpoints.rb +11 -0
- data/lib/taskworld/request.rb +36 -0
- data/lib/taskworld/version.rb +1 -1
- data/lib/taskworld.rb +10 -4
- data/taskworld.gemspec +3 -0
- metadata +53 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7f7de65beb4c7cdbb0fe2157afbee6c240feed9
|
4
|
+
data.tar.gz: a9c1b51583c5ac0fb8a2465e7e46db19740d7a35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a86938d85728c3c09f34844c4a7eed243bcd2ee922a4ef5816df43096e602097db1d3a37cfba7dc8c53e25927a59ec9929600ba61f1da8134fd6c9849329df
|
7
|
+
data.tar.gz: 7366978dec0657e1f5f049d8cca81ceef6e23bf8fe2fe4d3fd124afdef2a5787ad4fe2682cb5280577fb3de08e49c42fce3fc7971c465e04ee7bcc831d37224b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Taskworld
|
2
|
+
[](https://badge.fury.io/rb/taskworld)
|
3
|
+
[](https://travis-ci.org/yshimada0330/taskworld)
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
5
|
+
A Ruby client for the Taskworld [Web](https://api.taskworld.com/) APIs.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,22 +22,18 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/taskworld. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
25
|
+
### Web Client
|
36
26
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
27
|
+
```ruby
|
28
|
+
Taskworld::Client.configure do |config|
|
29
|
+
config.server = :usa
|
30
|
+
config.email = 'boyd.bankfein@goldmangoose.com'
|
31
|
+
config.password = 'm0reM0n1th@nG0D!'
|
32
|
+
end
|
33
|
+
```
|
42
34
|
|
43
|
-
|
35
|
+
#### Get all projects
|
36
|
+
```ruby
|
37
|
+
client = Taskworld::Client.new
|
38
|
+
client.project_get_all(space_id: '59eecc4bb0a6a6bc83f5fc39')
|
39
|
+
```
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Taskworld
|
2
|
+
class Client
|
3
|
+
include Connection
|
4
|
+
include Request
|
5
|
+
include Endpoints
|
6
|
+
|
7
|
+
attr_accessor :endpoint, :access_token, :default_space_id, :workspaces
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def configure
|
11
|
+
block_given? ? yield(Config) : Config
|
12
|
+
end
|
13
|
+
|
14
|
+
def config
|
15
|
+
Config
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@endpoint ||= Config::ENDPOINTS.fetch(Config.server, Config::DEFAULT_ENDPONT)
|
21
|
+
auth
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def auth
|
27
|
+
response = post('auth', email: Config.email, password: Config.password)
|
28
|
+
raise 'fail auth' unless response['ok']
|
29
|
+
@access_token = response['access_token']
|
30
|
+
@default_space_id = response['default_space_id']
|
31
|
+
@workspaces = response['workspaces']
|
32
|
+
end
|
33
|
+
|
34
|
+
def call_required_field_api(required_fields, options)
|
35
|
+
required_fields.each do |field|
|
36
|
+
throw ArgumentError.new("Required arguments :#{field} missing") if options[field].nil?
|
37
|
+
end
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Taskworld
|
2
|
+
module Config
|
3
|
+
extend self
|
4
|
+
|
5
|
+
DEFAULT_ENDPONT = 'api.taskworld.com'.freeze
|
6
|
+
ENDPOINTS = {
|
7
|
+
asia: 'asia-api.taskworld.com',
|
8
|
+
europe: 'europe-api.taskworld.com',
|
9
|
+
usa: DEFAULT_ENDPONT
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
attr_accessor :server, :email, :password
|
13
|
+
|
14
|
+
def reset
|
15
|
+
self.server = nil
|
16
|
+
self.email = nil
|
17
|
+
self.password = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
reset
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Taskworld
|
2
|
+
module Connection
|
3
|
+
private
|
4
|
+
|
5
|
+
def connection
|
6
|
+
options = {
|
7
|
+
headers: { Accept: 'application/json; charset=utf-8' }
|
8
|
+
}
|
9
|
+
|
10
|
+
# request_options = {}
|
11
|
+
# request_options[:timeout] = timeout if timeout
|
12
|
+
# request_options[:open_timeout] = open_timeout if open_timeout
|
13
|
+
# options[:request] = request_options if request_options.any?
|
14
|
+
|
15
|
+
::Faraday::Connection.new("https://#{endpoint}/v1/", options) do |connection|
|
16
|
+
connection.use ::Faraday::Request::Multipart
|
17
|
+
connection.use ::Faraday::Request::UrlEncoded
|
18
|
+
connection.use ::Faraday::Response::RaiseError
|
19
|
+
connection.use ::FaradayMiddleware::ParseJson
|
20
|
+
connection.adapter ::Faraday.default_adapter
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Taskworld
|
2
|
+
module Request
|
3
|
+
def get(path, options = {})
|
4
|
+
request(:get, path, options)
|
5
|
+
end
|
6
|
+
|
7
|
+
def post(path, options = {})
|
8
|
+
request(:post, path, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def put(path, options = {})
|
12
|
+
request(:put, path, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(path, options = {})
|
16
|
+
request(:delete, path, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def request(method, path, options)
|
22
|
+
options = options.merge(access_token: access_token) unless access_token.nil?
|
23
|
+
response = connection.send(method) do |request|
|
24
|
+
case method
|
25
|
+
when :get, :delete
|
26
|
+
request.url(path, options)
|
27
|
+
when :post, :put
|
28
|
+
request.path = path
|
29
|
+
request.body = options unless options.empty?
|
30
|
+
end
|
31
|
+
request.options.merge!(options.delete(:request)) if options.key?(:request)
|
32
|
+
end
|
33
|
+
response.body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/taskworld/version.rb
CHANGED
data/lib/taskworld.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'taskworld/version'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
require 'taskworld/config'
|
8
|
+
require 'taskworld/connection'
|
9
|
+
require 'taskworld/request'
|
10
|
+
require 'taskworld/endpoints'
|
11
|
+
require 'taskworld/client'
|
data/taskworld.gemspec
CHANGED
@@ -21,7 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.add_dependency 'faraday', '>= 0.15'
|
25
|
+
spec.add_dependency 'faraday_middleware'
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.16"
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency 'webmock'
|
27
30
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taskworld
|
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
|
- shimada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +80,20 @@ dependencies:
|
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
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'
|
55
97
|
description: Taskworld Web API client.
|
56
98
|
email:
|
57
99
|
- yoshihiro.shimada@studyplus.jp
|
@@ -70,6 +112,14 @@ files:
|
|
70
112
|
- bin/console
|
71
113
|
- bin/setup
|
72
114
|
- lib/taskworld.rb
|
115
|
+
- lib/taskworld/client.rb
|
116
|
+
- lib/taskworld/config.rb
|
117
|
+
- lib/taskworld/connection.rb
|
118
|
+
- lib/taskworld/endpoints.rb
|
119
|
+
- lib/taskworld/endpoints/project.rb
|
120
|
+
- lib/taskworld/endpoints/task.rb
|
121
|
+
- lib/taskworld/endpoints/tasklist.rb
|
122
|
+
- lib/taskworld/request.rb
|
73
123
|
- lib/taskworld/version.rb
|
74
124
|
- taskworld.gemspec
|
75
125
|
homepage: https://github.com/yshimada0330/taskworld
|
@@ -92,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
142
|
version: '0'
|
93
143
|
requirements: []
|
94
144
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.6.
|
145
|
+
rubygems_version: 2.6.13
|
96
146
|
signing_key:
|
97
147
|
specification_version: 4
|
98
148
|
summary: Taskworld Web API client.
|