trelloapi 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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +11 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/lib/.DS_Store +0 -0
  13. data/lib/trello.rb +163 -0
  14. data/lib/trello/.DS_Store +0 -0
  15. data/lib/trello/action.rb +68 -0
  16. data/lib/trello/association.rb +14 -0
  17. data/lib/trello/association_proxy.rb +42 -0
  18. data/lib/trello/attachment.rb +40 -0
  19. data/lib/trello/authorization.rb +187 -0
  20. data/lib/trello/basic_data.rb +132 -0
  21. data/lib/trello/board.rb +201 -0
  22. data/lib/trello/card.rb +456 -0
  23. data/lib/trello/checklist.rb +142 -0
  24. data/lib/trello/client.rb +120 -0
  25. data/lib/trello/comment.rb +62 -0
  26. data/lib/trello/configuration.rb +68 -0
  27. data/lib/trello/core_ext/array.rb +6 -0
  28. data/lib/trello/core_ext/hash.rb +6 -0
  29. data/lib/trello/core_ext/string.rb +6 -0
  30. data/lib/trello/cover_image.rb +8 -0
  31. data/lib/trello/has_actions.rb +9 -0
  32. data/lib/trello/item.rb +37 -0
  33. data/lib/trello/item_state.rb +30 -0
  34. data/lib/trello/json_utils.rb +64 -0
  35. data/lib/trello/label.rb +108 -0
  36. data/lib/trello/label_name.rb +31 -0
  37. data/lib/trello/list.rb +114 -0
  38. data/lib/trello/member.rb +112 -0
  39. data/lib/trello/multi_association.rb +12 -0
  40. data/lib/trello/net.rb +39 -0
  41. data/lib/trello/notification.rb +61 -0
  42. data/lib/trello/organization.rb +68 -0
  43. data/lib/trello/plugin_datum.rb +34 -0
  44. data/lib/trello/token.rb +36 -0
  45. data/lib/trello/webhook.rb +103 -0
  46. data/trello.gemspec +41 -0
  47. metadata +161 -0
@@ -0,0 +1,12 @@
1
+ module Trello
2
+ class MultiAssociation < Association
3
+ extend Forwardable
4
+
5
+ def_delegator :target, :count
6
+
7
+ def initialize(owner, target = [])
8
+ super
9
+ @proxy = AssociationProxy.new(self)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,39 @@
1
+ module Trello
2
+ Request = Struct.new "Request", :verb, :uri, :headers, :body
3
+ Response = Struct.new "Response", :code, :headers, :body
4
+
5
+ class TInternet
6
+ class << self
7
+ require "rest_client"
8
+
9
+ def execute(request)
10
+ try_execute request
11
+ end
12
+
13
+ private
14
+
15
+ def try_execute(request)
16
+ begin
17
+ if request
18
+ result = execute_core request
19
+ Response.new(200, {}, result)
20
+ end
21
+ rescue RestClient::Exception => e
22
+ raise if !e.respond_to?(:http_code) || e.http_code.nil?
23
+ Response.new(e.http_code, {}, e.http_body)
24
+ end
25
+ end
26
+
27
+ def execute_core(request)
28
+ RestClient.proxy = ENV['HTTP_PROXY'] if ENV['HTTP_PROXY']
29
+ RestClient::Request.execute(
30
+ method: request.verb,
31
+ url: request.uri.to_s,
32
+ headers: request.headers,
33
+ payload: request.body,
34
+ timeout: 10
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,61 @@
1
+ module Trello
2
+
3
+ # @!attribute [r] id
4
+ # @return [String]
5
+ # @!attribute [rw] unread
6
+ # @return [Boolean]
7
+ # @!attribute [r] type
8
+ # @return [Object]
9
+ # @!attribute [r] date
10
+ # @return [Datetime]
11
+ # @!attribute [rw] data
12
+ # @return [Object]
13
+ # @!attribute [r] member_creator_id,
14
+ # @return [String]
15
+ class Notification < BasicData
16
+ register_attributes :id, :unread, :type, :date, :data, :member_creator_id,
17
+ read_only: [ :id, :unread, :type, :date, :member_creator_id ]
18
+ validates_presence_of :id, :type, :date, :member_creator_id
19
+
20
+ class << self
21
+ # Locate a notification by its id
22
+ def find(id, params = {})
23
+ client.find(:notification, id, params)
24
+ end
25
+ end
26
+
27
+ def update_fields(fields)
28
+ attributes[:id] = fields['id']
29
+ attributes[:unread] = fields['unread']
30
+ attributes[:type] = fields['type']
31
+ attributes[:date] = fields['date']
32
+ attributes[:data] = fields['data']
33
+ attributes[:member_creator_id] = fields['idMemberCreator']
34
+ self
35
+ end
36
+
37
+ alias :unread? :unread
38
+
39
+ one :member_creator, path: :members, via: Member, using: :member_creator_id
40
+
41
+ def board
42
+ Board.from_response client.get("/notifications/#{id}/board")
43
+ end
44
+
45
+ def list
46
+ List.from_response client.get("/notifications/#{id}/list")
47
+ end
48
+
49
+ def card
50
+ Card.from_response client.get("/notifications/#{id}/card")
51
+ end
52
+
53
+ def member
54
+ Member.from_response client.get("/notifications/#{id}/member")
55
+ end
56
+
57
+ def organization
58
+ Organization.from_response client.get("/notifications/#{id}/organization")
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,68 @@
1
+ module Trello
2
+ # Organizations are useful for linking members together.
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] name
7
+ # @return [String]
8
+ # @!attribute [r] display_name
9
+ # @return [String]
10
+ # @!attribute [r] description
11
+ # @return [String]
12
+ # @!attribute [r] url
13
+ # @return [String]
14
+ class Organization < BasicData
15
+ register_attributes :id, :name, :display_name, :description, :url, :invited,
16
+ :website, :logo_hash, :billable_member_count, :active_billable_member_count,
17
+ :memberships,
18
+ readonly: [ :id, :name, :display_name, :description, :url, :invited,
19
+ :website, :logo_hash, :billable_member_count, :active_billable_member_count,
20
+ :memberships ]
21
+ validates_presence_of :id, :name
22
+
23
+ include HasActions
24
+
25
+ class << self
26
+ # Find an organization by its id.
27
+ def find(id, params = {})
28
+ client.find(:organization, id, params)
29
+ end
30
+ end
31
+
32
+ # Update the fields of an organization.
33
+ #
34
+ # Supply a hash of string keyed data retrieved from the Trello API representing
35
+ # an Organization.
36
+ def update_fields(fields)
37
+ attributes[:id] = fields['id']
38
+ attributes[:name] = fields['name']
39
+ attributes[:display_name] = fields['displayName']
40
+ attributes[:description] = fields['desc']
41
+ attributes[:url] = fields['url']
42
+ attributes[:invited] = fields['invited']
43
+ attributes[:website] = fields['website']
44
+ attributes[:logo_hash] = fields['logoHash']
45
+ attributes[:billable_member_count] = fields['billableMemberCount']
46
+ attributes[:active_billable_member_count] = fields['activeBillableMemberCount']
47
+ attributes[:memberships] = fields['memberships']
48
+ self
49
+ end
50
+
51
+ # Returns a list of boards under this organization.
52
+ def boards
53
+ boards = Board.from_response client.get("/organizations/#{id}/boards/all")
54
+ MultiAssociation.new(self, boards).proxy
55
+ end
56
+
57
+ # Returns an array of members associated with the organization.
58
+ def members(params = {})
59
+ members = Member.from_response client.get("/organizations/#{id}/members/all", params)
60
+ MultiAssociation.new(self, members).proxy
61
+ end
62
+
63
+ # :nodoc:
64
+ def request_prefix
65
+ "/organizations/#{id}"
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ module Trello
2
+ # A file or url that is linked to a Trello card
3
+ #
4
+ # @!attribute id
5
+ # @return [String]
6
+ # @!attribute idPlugin
7
+ # @return [String]
8
+ # @!attribute scope
9
+ # @return [String]
10
+ # @!attribute idModel
11
+ # @return [String]
12
+ # @!attribute value
13
+ # @return [String]
14
+ # @!attribute access
15
+ # @return [String]
16
+ class PluginDatum < BasicData
17
+ # Update the fields of a plugin.
18
+ register_attributes :id, :idPlugin, :scope, :idModel, :value, :access
19
+
20
+
21
+ # Supply a hash of stringkeyed data retrieved from the Trello API representing
22
+ # an attachment.
23
+ def update_fields(fields)
24
+ attributes[:id] = fields['id']
25
+ attributes[:idPlugin] = fields['idPlugin']
26
+ attributes[:scope] = fields['scope']
27
+ attributes[:value] = JSON.parse fields['value']
28
+ attributes[:idModel] = fields['idModel']
29
+ attributes[:access] = fields['access']
30
+ self
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,36 @@
1
+ module Trello
2
+
3
+ # @!attribute [r] id
4
+ # @return [String]
5
+ # @!attribute [r] member_id
6
+ # @return [String]
7
+ # @!attribute [r] created_at
8
+ # @return [Datetime]
9
+ # @!attribute [r] permissions
10
+ # @return [Object]
11
+ # @!attribute [r] webhooks
12
+ # @return [Object]
13
+ class Token < BasicData
14
+ register_attributes :id, :member_id, :created_at, :permissions, :webhooks,
15
+ readonly: [ :id, :member_id, :created_at, :permissions, :webhooks ]
16
+
17
+ class << self
18
+ # Finds a token
19
+ def find(token, params = {webhooks: true})
20
+ client.find(:token, token, params)
21
+ end
22
+ end
23
+
24
+ # :nodoc:
25
+ def update_fields(fields)
26
+ attributes[:id] = fields['id']
27
+ attributes[:member_id] = fields['idMember']
28
+ attributes[:created_at] = Time.iso8601(fields['dateCreated'])
29
+ attributes[:permissions] = fields['permissions'] || {}
30
+ attributes[:webhooks] = fields['webhooks']
31
+ end
32
+
33
+ # Returns a reference to the user who authorized the token.
34
+ one :member, path: :members, using: :member_id
35
+ end
36
+ end
@@ -0,0 +1,103 @@
1
+ module Trello
2
+ # A webhook is a URL called each time a specified model is updated
3
+ #
4
+ # @!attribute [r] id
5
+ # @return [String]
6
+ # @!attribute [r] description
7
+ # @return [String]
8
+ # @!attribute [r] id_model
9
+ # @return [String] A 24-character hex string
10
+ # @!attribute [r] callback_url
11
+ # @return [String]
12
+ # @!attribute [r] active
13
+ # @return [Boolean]
14
+ class Webhook < BasicData
15
+ register_attributes :id, :description, :id_model, :callback_url, :active,
16
+ readonly: [ :id ]
17
+ validates_presence_of :id, :id_model, :callback_url
18
+ validates_length_of :description, in: 1..16384
19
+
20
+ class << self
21
+ # Find a specific webhook by its ID.
22
+ #
23
+ # @raise [Trello::Error] if a Webhook with the given ID can't be found.
24
+ # @return [Trello::Webhook] the Webhook with the given ID.
25
+ def find(id, params = {})
26
+ client.find(:webhook, id, params)
27
+ end
28
+
29
+ # Create a new webhook and save it to Trello.
30
+ #
31
+ # @param [Hash] options
32
+ #
33
+ # @option options [String] :description (optional) A string with a length from 0 to 16384
34
+ # @option options [String] :callback_url (required) A valid URL that is
35
+ # reachable with a HEAD request
36
+ # @option options [String] :id_model (required) id of the model that should be hooked
37
+ #
38
+ # @raise [Trello::Error] if the Webhook could not be created.
39
+ #
40
+ # @return [Trello::Webhook]
41
+ def create(options)
42
+ client.create(:webhook,
43
+ 'description' => options[:description],
44
+ 'idModel' => options[:id_model],
45
+ 'callbackURL' => options[:callback_url])
46
+ end
47
+ end
48
+
49
+ # @return [Trello::Webhook] self
50
+ def update_fields(fields)
51
+ attributes[:id] = fields['id']
52
+ attributes[:description] = fields['description'] || fields[:description]
53
+ attributes[:id_model] = fields['idModel'] || fields[:id_model]
54
+ attributes[:callback_url] = fields['callbackURL'] || fields[:callback_url]
55
+ attributes[:active] = fields['active']
56
+ self
57
+ end
58
+
59
+ # Save the webhook.
60
+ #
61
+ # @raise [Trello::Error] if the Webhook could not be saved.
62
+ #
63
+ # @return [String] the JSON representation of the saved webhook.
64
+ def save
65
+ # If we have an id, just update our fields.
66
+ return update! if id
67
+
68
+ from_response client.post("/webhooks", {
69
+ description: description,
70
+ idModel: id_model,
71
+ callbackURL: callback_url
72
+ })
73
+ end
74
+
75
+ # Update the webhook.
76
+ #
77
+ # @raise [Trello::Error] if the Webhook could not be saved.
78
+ #
79
+ # @return [String] the JSON representation of the updated webhook.
80
+ def update!
81
+ client.put("/webhooks/#{id}", {
82
+ description: description,
83
+ idModel: id_model,
84
+ callbackURL: callback_url,
85
+ active: active
86
+ })
87
+ end
88
+
89
+ # Delete this webhook
90
+ #
91
+ # @return [String] the JSON response from the Trello API
92
+ def delete
93
+ client.delete("/webhooks/#{id}")
94
+ end
95
+
96
+ # Check if the webhook is activated
97
+ #
98
+ # @return [Boolean]
99
+ def activated?
100
+ active
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "trelloapi"
7
+ spec.version = "0.1.1"
8
+ spec.authors = ["Canic Interactive"]
9
+ spec.email = ["nenad.mucic@canicinteractive.com"]
10
+
11
+ spec.summary = %q{This is a copy of ruby-trello 2.0.0 with small changes (this git will be deleted on new wersion of ruby-trello)}
12
+ spec.description = %q{Copy of ruby-trello 2.0.0 (do not use in your project this will be deleted on original ruby-trello update 2.1.0)}
13
+ spec.homepage = "https://rubygems.org/gems/trelloapi"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_runtime_dependency "activemodel",">= 3.2.0"
33
+ spec.add_runtime_dependency "addressable","~> 2.3"
34
+ spec.add_runtime_dependency "json",">= 0.0.0"
35
+ spec.add_runtime_dependency "oauth",">= 0.4.5"
36
+ spec.add_runtime_dependency "rest-client",">= 1.8.0"
37
+
38
+ # spec.add_development_dependency "bundler", "~> 1.14"
39
+ # spec.add_development_dependency "rake", "~> 10.0"
40
+ # spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trelloapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Canic Interactive
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.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: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: addressable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: oauth
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.0
83
+ description: Copy of ruby-trello 2.0.0 (do not use in your project this will be deleted
84
+ on original ruby-trello update 2.1.0)
85
+ email:
86
+ - nenad.mucic@canicinteractive.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".DS_Store"
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/.DS_Store
102
+ - lib/trello.rb
103
+ - lib/trello/.DS_Store
104
+ - lib/trello/action.rb
105
+ - lib/trello/association.rb
106
+ - lib/trello/association_proxy.rb
107
+ - lib/trello/attachment.rb
108
+ - lib/trello/authorization.rb
109
+ - lib/trello/basic_data.rb
110
+ - lib/trello/board.rb
111
+ - lib/trello/card.rb
112
+ - lib/trello/checklist.rb
113
+ - lib/trello/client.rb
114
+ - lib/trello/comment.rb
115
+ - lib/trello/configuration.rb
116
+ - lib/trello/core_ext/array.rb
117
+ - lib/trello/core_ext/hash.rb
118
+ - lib/trello/core_ext/string.rb
119
+ - lib/trello/cover_image.rb
120
+ - lib/trello/has_actions.rb
121
+ - lib/trello/item.rb
122
+ - lib/trello/item_state.rb
123
+ - lib/trello/json_utils.rb
124
+ - lib/trello/label.rb
125
+ - lib/trello/label_name.rb
126
+ - lib/trello/list.rb
127
+ - lib/trello/member.rb
128
+ - lib/trello/multi_association.rb
129
+ - lib/trello/net.rb
130
+ - lib/trello/notification.rb
131
+ - lib/trello/organization.rb
132
+ - lib/trello/plugin_datum.rb
133
+ - lib/trello/token.rb
134
+ - lib/trello/webhook.rb
135
+ - trello.gemspec
136
+ homepage: https://rubygems.org/gems/trelloapi
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.6.8
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: This is a copy of ruby-trello 2.0.0 with small changes (this git will be
160
+ deleted on new wersion of ruby-trello)
161
+ test_files: []