Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support query parameters for most model GET like methods #314

Merged
merged 8 commits into from
Dec 21, 2023
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ jobs:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
active_model:
- '6.0'
- '6.1'
- '7.0'
- '7.1'
http_client_gem:
- 'rest-client'
- 'faraday'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ group :development, :spec do

gem 'rest-client', '>= 1.8.0'

gem 'pry-byebug', '~> 3.9.0', :platforms => [:mri]
gem 'pry-byebug', '~> 3.10.1', :platforms => [:mri]
gem 'simplecov', :require => false, :platforms => [:mri, :mri_18, :mri_19, :mingw]
end
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ to, please just [create an issue](https://github.com/jeremytregunna/ruby-trello/

## Requirements

| Ruby \ ActiveModel | 6.0 | 6.1 | 7.0 |
| Ruby \ ActiveModel | 6.0 | 6.1 | 7.0 | 7.1 |
| ---- | ---- | ---- | ---- |
| 2.7 | ✅ | ✅ | ✅ |
| 3.0 | ✅ | ✅ | ✅ |
| 3.1 | ✅ | ✅ | ✅ |
| 2.7 | ✅ | ✅ | ✅ | ✅ |
| 3.0 | ✅ | ✅ | ✅ | ✅ |
| 3.1 | ✅ | ✅ | ✅ | ✅ |
| 3.2 | ✅ | ✅ | ✅ | ✅ |

- Use the newest version for Ruby 2.7.0 or newer support.
- Use version 3.2.0 or earlier for Ruby 2.5 ~ 2.6 support.
Expand Down
16 changes: 8 additions & 8 deletions lib/trello/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ def search(query, opts = {})
end

# Returns the board this action occurred on.
def board
Board.from_response client.get("/actions/#{id}/board")
def board(params = {})
Board.from_response client.get("/actions/#{id}/board", params)
end

# Returns the card the action occurred on.
def card
Card.from_response client.get("/actions/#{id}/card")
def card(params = {})
Card.from_response client.get("/actions/#{id}/card", params)
end

# Returns the list the action occurred on.
def list
List.from_response client.get("/actions/#{id}/list")
def list(params = {})
List.from_response client.get("/actions/#{id}/list", params)
end

# Returns the list the action occurred on.
def member_creator
Member.from_response client.get("/actions/#{id}/memberCreator")
def member_creator(params = {})
Member.from_response client.get("/actions/#{id}/memberCreator", params)
end
end
end
4 changes: 2 additions & 2 deletions lib/trello/board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class Board < BasicData

class << self
# @return [Array<Trello::Board>] all boards for the current user
def all
from_response client.get("/members/#{Member.find(:me).username}/boards")
def all(params = {})
from_response client.get("/members/#{Member.find(:me).username}/boards", params)
end
end

Expand Down
21 changes: 11 additions & 10 deletions lib/trello/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def cover_image(params = {})
# List of custom field values on the card, only the ones that have been set
many :custom_field_items, path: 'customFieldItems'

def check_item_states
states = CheckItemState.from_response client.get("/cards/#{self.id}/checkItemStates")
def check_item_states(params = {})
states = CheckItemState.from_response client.get("/cards/#{self.id}/checkItemStates", params)
MultiAssociation.new(self, states).proxy
end

Expand All @@ -116,8 +116,8 @@ def check_item_states
# Returns a list of members who are assigned to this card.
#
# @return [Array<Trello::Member>]
def members
members = Member.from_response client.get("/cards/#{self.id}/members")
def members(params = {})
members = Member.from_response client.get("/cards/#{self.id}/members", params)
MultiAssociation.new(self, members).proxy
end

Expand All @@ -127,8 +127,8 @@ def members
# accuracy over network performance
#
# @return [Array<Trello::Member>]
def voters
Member.from_response client.get("/cards/#{id}/membersVoted")
def voters(params = {})
Member.from_response client.get("/cards/#{id}/membersVoted", params)
end

# Delete this card
Expand Down Expand Up @@ -285,8 +285,8 @@ def add_attachment(attachment, name = '')
end

# Retrieve a list of attachments
def attachments
attachments = Attachment.from_response client.get("/cards/#{id}/attachments")
def attachments(params = {})
attachments = Attachment.from_response client.get("/cards/#{id}/attachments", params)
MultiAssociation.new(self, attachments).proxy
end

Expand All @@ -301,8 +301,9 @@ def request_prefix
end

# Retrieve a list of comments
def comments
comments = Comment.from_response client.get("/cards/#{id}/actions", filter: "commentCard")
def comments(params = {})
params[:filter] ||= "commentCard"
comments = Comment.from_response client.get("/cards/#{id}/actions", params)
end

# Find the creation date
Expand Down
12 changes: 6 additions & 6 deletions lib/trello/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ def find(action_id)
end

# Returns the board this comment is located
def board
Board.from_response client.get("/actions/#{id}/board")
def board(params = {})
Board.from_response client.get("/actions/#{id}/board", params)
end

# Returns the card the comment is located
def card
Card.from_response client.get("/actions/#{id}/card")
def card(params = {})
Card.from_response client.get("/actions/#{id}/card", params)
end

# Returns the list the comment is located
def list
List.from_response client.get("/actions/#{id}/list")
def list(params = {})
List.from_response client.get("/actions/#{id}/list", params)
end

# Deletes the comment from the card
Expand Down
20 changes: 10 additions & 10 deletions lib/trello/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ class Notification < BasicData

one :creator, path: :members, via: Member, using: :creator_id

def board
Board.from_response client.get("/notifications/#{id}/board")
def board(params = {})
Board.from_response client.get("/notifications/#{id}/board", params)
end

def list
List.from_response client.get("/notifications/#{id}/list")
def list(params = {})
List.from_response client.get("/notifications/#{id}/list", params)
end

def card
Card.from_response client.get("/notifications/#{id}/card")
def card(params = {})
Card.from_response client.get("/notifications/#{id}/card", params)
end

def member
Member.from_response client.get("/notifications/#{id}/member")
def member(params = {})
Member.from_response client.get("/notifications/#{id}/member", params)
end

def organization
Organization.from_response client.get("/notifications/#{id}/organization")
def organization(params = {})
Organization.from_response client.get("/notifications/#{id}/organization", params)
end
end
end
4 changes: 2 additions & 2 deletions lib/trello/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def find(id, params = {})
end

# Returns a list of boards under this organization.
def boards
boards = Board.from_response client.get("/organizations/#{id}/boards/all")
def boards(params = {})
boards = Board.from_response client.get("/organizations/#{id}/boards", params)
MultiAssociation.new(self, boards).proxy
end

Expand Down
12 changes: 9 additions & 3 deletions matrixeval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ matrix:
variants:
- key: 2.7
container:
image: ruby:2.7.5
image: ruby:2.7.8
- key: 3.0
container:
image: ruby:3.0.3
image: ruby:3.0.6
default: true
- key: 3.1
container:
image: ruby:3.1.0
image: ruby:3.1.4
- key: 3.2
container:
image: ruby:3.2.2
# - key: jruby-9.3
# container:
# image: jruby:9.3
Expand All @@ -38,6 +41,9 @@ matrix:
- key: 7.0
env:
ACTIVE_MODEL_VERSION: "~> 7.0.0"
- key: 7.1
env:
ACTIVE_MODEL_VERSION: "~> 7.1.2"
http_client_gem:
variants:
- key: faraday
Expand Down
8 changes: 4 additions & 4 deletions spec/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module Trello
before do
allow(client)
.to receive(:get)
.with('/actions/4ee2482134a81a757a08af47/board')
.with('/actions/4ee2482134a81a757a08af47/board', {})
.and_return payload
end

Expand All @@ -87,7 +87,7 @@ module Trello
before do
allow(client)
.to receive(:get)
.with('/actions/4ee2482134a81a757a08af47/card')
.with('/actions/4ee2482134a81a757a08af47/card', {})
.and_return payload
end

Expand All @@ -102,7 +102,7 @@ module Trello
before do
allow(client)
.to receive(:get)
.with('/actions/4ee2482134a81a757a08af47/list')
.with('/actions/4ee2482134a81a757a08af47/list', {})
.and_return payload
end

Expand All @@ -116,7 +116,7 @@ module Trello
before do
allow(client)
.to receive(:get)
.with('/actions/4ee2482134a81a757a08af47/memberCreator')
.with('/actions/4ee2482134a81a757a08af47/memberCreator', {})
.and_return user_payload
end

Expand Down
2 changes: 1 addition & 1 deletion spec/association_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Trello

allow(client)
.to receive(:get)
.with('/organizations/4ee7e59ae582acdec8000291/boards/all')
.with('/organizations/4ee7e59ae582acdec8000291/boards', {})
.and_return boards_payload
end

Expand Down
2 changes: 1 addition & 1 deletion spec/board_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module Trello

allow(client)
.to receive(:get)
.with("/members/testuser/boards")
.with("/members/testuser/boards", {})
.and_return boards_payload
end

Expand Down
10 changes: 5 additions & 5 deletions spec/card_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ module Trello

allow(client)
.to receive(:get)
.with("/cards/abcdef123456789123456789/members")
.with("/cards/abcdef123456789123456789/members", {})
.and_return user_payload
end

Expand Down Expand Up @@ -597,7 +597,7 @@ module Trello
no_voters = JSON.generate([])
expect(client)
.to receive(:get)
.with("/cards/#{card.id}/membersVoted")
.with("/cards/#{card.id}/membersVoted", {})
.and_return(no_voters)

card.voters
Expand All @@ -606,7 +606,7 @@ module Trello
voters = JSON.generate([user_details])
expect(client)
.to receive(:get)
.with("/cards/#{card.id}/membersVoted")
.with("/cards/#{card.id}/membersVoted", {})
.and_return(voters)

expect(card.voters.first).to be_kind_of Trello::Member
Expand Down Expand Up @@ -750,7 +750,7 @@ module Trello

allow(client)
.to receive(:get)
.with("/cards/abcdef123456789123456789/attachments")
.with("/cards/abcdef123456789123456789/attachments", {})
.and_return attachments_payload

expect(card.board).to_not be_nil
Expand Down Expand Up @@ -779,7 +779,7 @@ module Trello

allow(client)
.to receive(:get)
.with("/cards/abcdef123456789123456789/attachments")
.with("/cards/abcdef123456789123456789/attachments", {})
.and_return attachments_payload

card.remove_attachment(card.attachments.first)
Expand Down
Loading
Loading