height-api 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +3 -1
- data/height-api.gemspec +2 -0
- data/lib/height/api.rb +2 -0
- data/lib/height/api/activities.rb +9 -0
- data/lib/height/api/tasks.rb +4 -1
- data/lib/height/api/users.rb +9 -0
- data/lib/height/client.rb +4 -0
- data/lib/height/list_response.rb +11 -0
- data/lib/height/model.rb +4 -0
- data/lib/height/model/activity.rb +8 -0
- data/lib/height/model/base.rb +26 -4
- data/lib/height/model/list.rb +1 -1
- data/lib/height/model/task.rb +18 -0
- data/lib/height/model/user.rb +17 -0
- data/lib/height/version.rb +1 -1
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feae01339c558850f5526c5b682ced07fdca19a311f7bc63467a12b016490ecb
|
4
|
+
data.tar.gz: f16e34312d33ffb9da2cdd3429828a4a44badc0d23756ca320018cbe75d0e8d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f847f1cbbb00c4760aefc083afc27e22d0cb09a36861f04346ad8cc33b52d1c6b830d9549f8bbffb38107f41f81a2d7fe7146fd5ba626806f4f44e96702ccac
|
7
|
+
data.tar.gz: 0aae4b6a12e41ff30fd3022a3eeec64795aef40f8bdc0055470d94d8d8b510849cc3d16d2add97bc2f96161626868c6f0eb75843a6e28507c3e605065d3b28c5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.0.4
|
4
|
+
|
5
|
+
- Fix issue with camel cased attributes
|
6
|
+
- Add activities
|
7
|
+
- Fix typo in List method name
|
8
|
+
- Add users endpoint
|
9
|
+
- Add user.tasks
|
10
|
+
- Allow to include lists in tasks search
|
11
|
+
|
12
|
+
## 0.0.3
|
13
|
+
|
14
|
+
- Fixes loading order when requiring this gem
|
15
|
+
|
3
16
|
## 0.0.2
|
4
17
|
|
5
18
|
- Update task
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
height-api (0.0.
|
4
|
+
height-api (0.0.4)
|
5
|
+
dry-inflector (~> 0.2.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -12,6 +13,7 @@ GEM
|
|
12
13
|
crack (0.4.5)
|
13
14
|
rexml
|
14
15
|
diff-lcs (1.4.4)
|
16
|
+
dry-inflector (0.2.0)
|
15
17
|
hashdiff (1.0.1)
|
16
18
|
public_suffix (4.0.6)
|
17
19
|
rake (12.3.3)
|
data/height-api.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
end
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
|
+
spec.add_dependency 'dry-inflector', '~> 0.2.0'
|
27
|
+
|
26
28
|
spec.add_development_dependency 'byebug', '~> 11.1.3'
|
27
29
|
spec.add_development_dependency 'vcr', '~> 6.0.0'
|
28
30
|
spec.add_development_dependency 'webmock', '~> 3.12.2'
|
data/lib/height/api.rb
CHANGED
data/lib/height/api/tasks.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
class Height::API::Tasks
|
2
2
|
class << self
|
3
|
-
def search(filter)
|
3
|
+
def search(filter, incl = nil)
|
4
4
|
query = { 'filters' => filter.to_json }
|
5
|
+
|
6
|
+
query.merge!({ 'include' => incl.to_json }) if incl
|
7
|
+
|
5
8
|
res = Height::Request.get('tasks', query)
|
6
9
|
|
7
10
|
Height::ListResponse.parse(res.body)
|
data/lib/height/client.rb
CHANGED
data/lib/height/list_response.rb
CHANGED
@@ -8,8 +8,15 @@ class Height::ListResponse
|
|
8
8
|
|
9
9
|
new(items)
|
10
10
|
end
|
11
|
+
|
12
|
+
def build(ary)
|
13
|
+
items = ary.map { |item| Height::Model.for(item) }
|
14
|
+
new(items)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
18
|
+
attr_reader :items
|
19
|
+
|
13
20
|
def initialize(items)
|
14
21
|
@items = items
|
15
22
|
end
|
@@ -25,4 +32,8 @@ class Height::ListResponse
|
|
25
32
|
def each(&block)
|
26
33
|
@items.each(&block)
|
27
34
|
end
|
35
|
+
|
36
|
+
def last
|
37
|
+
@items.last
|
38
|
+
end
|
28
39
|
end
|
data/lib/height/model.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'height/model/base'
|
2
|
+
require 'height/model/activity'
|
2
3
|
require 'height/model/list'
|
3
4
|
require 'height/model/task'
|
5
|
+
require 'height/model/user'
|
4
6
|
|
5
7
|
module Height::Model
|
6
8
|
def self.for(attrs)
|
7
9
|
model = attrs['model'].capitalize
|
8
10
|
|
11
|
+
model = attrs['type'].capitalize if model == 'View'
|
12
|
+
|
9
13
|
Object.const_get("Height::Model::#{model}").new(attrs)
|
10
14
|
end
|
11
15
|
end
|
data/lib/height/model/base.rb
CHANGED
@@ -1,12 +1,34 @@
|
|
1
|
+
require 'dry/inflector'
|
2
|
+
|
1
3
|
module Height::Model
|
2
4
|
class Base
|
3
5
|
def initialize(attrs)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
inflector = Dry::Inflector.new
|
7
|
+
|
8
|
+
self.attributes.each do |name|
|
9
|
+
key = inflector.camelize_lower(name.to_s)
|
10
|
+
|
11
|
+
self.instance_variable_set("@#{name}", attrs[key])
|
12
|
+
define_singleton_method(name) do
|
13
|
+
self.instance_variable_get("@#{name}")
|
8
14
|
end
|
9
15
|
end
|
16
|
+
|
17
|
+
self.related_models.each do |name|
|
18
|
+
key = inflector.camelize_lower(name.to_s)
|
19
|
+
next unless attrs[key]
|
20
|
+
|
21
|
+
items = Height::ListResponse.build(attrs[key])
|
22
|
+
|
23
|
+
self.instance_variable_set("@#{name}", items)
|
24
|
+
define_singleton_method(name) do
|
25
|
+
self.instance_variable_get("@#{name}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def related_models
|
31
|
+
[]
|
10
32
|
end
|
11
33
|
end
|
12
34
|
end
|
data/lib/height/model/list.rb
CHANGED
data/lib/height/model/task.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Height::Model
|
2
2
|
class Task < Base
|
3
|
+
include Enumerable
|
4
|
+
|
3
5
|
def attributes
|
4
6
|
[
|
5
7
|
:id, :index, :list_ids, :name, :description, :status,
|
@@ -9,8 +11,24 @@ module Height::Model
|
|
9
11
|
]
|
10
12
|
end
|
11
13
|
|
14
|
+
def related_models
|
15
|
+
[ :lists ]
|
16
|
+
end
|
17
|
+
|
12
18
|
def update(attrs)
|
13
19
|
Height::API::Tasks.update_task(id, attrs)
|
14
20
|
end
|
21
|
+
|
22
|
+
def activities
|
23
|
+
query = {
|
24
|
+
"taskId" => [id]
|
25
|
+
}
|
26
|
+
|
27
|
+
Height::API::Activities.list(query)
|
28
|
+
end
|
29
|
+
|
30
|
+
def comments
|
31
|
+
activities.select { |activity| activity.type == 'comment' }
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Height::Model
|
2
|
+
class User < Base
|
3
|
+
def attributes
|
4
|
+
[:id, :state, :email, :username, :firstname, :lastname, :access, :created_at, :picture_url]
|
5
|
+
end
|
6
|
+
|
7
|
+
def tasks
|
8
|
+
filters = {
|
9
|
+
"assigneesIds" => {
|
10
|
+
"values" => [id]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
Height::API::Tasks.search(filters)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/height/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: height-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauro Morales
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-inflector
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.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.2.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: byebug
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +87,18 @@ files:
|
|
73
87
|
- lib/height-api.rb
|
74
88
|
- lib/height.rb
|
75
89
|
- lib/height/api.rb
|
90
|
+
- lib/height/api/activities.rb
|
76
91
|
- lib/height/api/lists.rb
|
77
92
|
- lib/height/api/tasks.rb
|
93
|
+
- lib/height/api/users.rb
|
78
94
|
- lib/height/client.rb
|
79
95
|
- lib/height/list_response.rb
|
80
96
|
- lib/height/model.rb
|
97
|
+
- lib/height/model/activity.rb
|
81
98
|
- lib/height/model/base.rb
|
82
99
|
- lib/height/model/list.rb
|
83
100
|
- lib/height/model/task.rb
|
101
|
+
- lib/height/model/user.rb
|
84
102
|
- lib/height/request.rb
|
85
103
|
- lib/height/response.rb
|
86
104
|
- lib/height/version.rb
|
@@ -106,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
124
|
- !ruby/object:Gem::Version
|
107
125
|
version: '0'
|
108
126
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.1.6
|
110
128
|
signing_key:
|
111
129
|
specification_version: 4
|
112
130
|
summary: Ruby implementation for Height's API
|