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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba51907c385878d0e13943dcf989b437b92a14ca84e6fdb40ab4903509d008f4
4
- data.tar.gz: b618ec18a89d999d505967259a449442ec5cceb3c8f32dc48925738041874f84
3
+ metadata.gz: feae01339c558850f5526c5b682ced07fdca19a311f7bc63467a12b016490ecb
4
+ data.tar.gz: f16e34312d33ffb9da2cdd3429828a4a44badc0d23756ca320018cbe75d0e8d3
5
5
  SHA512:
6
- metadata.gz: 27459dbcd634b37eaf83ce30499711425fbb48ad9e4fb44f5a713fb54453a85fb35339b7a195e969d78f293f0a3c4b715cd2b4d8598f2174e274d4a4e344c4a9
7
- data.tar.gz: 0dfc1b9727fa50741538b74bdfacbd567f9621c74ad6a511675447dc16d80be1544f78cb5c5287c4b969b7c47939779c366aee59c5a0b071f862847dca045bd5
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.2)
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
@@ -1,4 +1,6 @@
1
1
  module Height::API
2
+ require 'height/api/activities'
2
3
  require 'height/api/lists'
3
4
  require 'height/api/tasks'
5
+ require 'height/api/users'
4
6
  end
@@ -0,0 +1,9 @@
1
+ class Height::API::Activities
2
+ class << self
3
+ def list(query)
4
+ res = Height::Request.get('activities', query)
5
+
6
+ Height::ListResponse.parse(res.body)
7
+ end
8
+ end
9
+ end
@@ -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)
@@ -0,0 +1,9 @@
1
+ class Height::API::Users
2
+ class << self
3
+ def list
4
+ res = Height::Request.get('users')
5
+
6
+ Height::ListResponse.parse(res.body)
7
+ end
8
+ end
9
+ end
data/lib/height/client.rb CHANGED
@@ -6,4 +6,8 @@ class Height::Client
6
6
  def tasks
7
7
  Height::API::Tasks
8
8
  end
9
+
10
+ def users
11
+ Height::API::Users
12
+ end
9
13
  end
@@ -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
@@ -0,0 +1,8 @@
1
+ module Height::Model
2
+ class Activity < Base
3
+ def attributes
4
+ [:id, :created_at, :task_id, :created_user_id, :type, :message,
5
+ :old_value, :new_value, :reactjis, :read_user_ids, :url]
6
+ end
7
+ end
8
+ end
@@ -1,12 +1,34 @@
1
+ require 'dry/inflector'
2
+
1
3
  module Height::Model
2
4
  class Base
3
5
  def initialize(attrs)
4
- self.attributes.each do |key|
5
- self.instance_variable_set("@#{key}", attrs[key.to_s])
6
- define_singleton_method(key) do
7
- self.instance_variable_get("@#{key}")
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
@@ -1,7 +1,7 @@
1
1
  module Height::Model
2
2
  class List < Base
3
3
  def attributes
4
- [:id, :type, :key, :description, :url, :appearence]
4
+ [:id, :type, :key, :description, :url, :appearance]
5
5
  end
6
6
 
7
7
  def tasks
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Height
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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-07 00:00:00.000000000 Z
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.0.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