Module: FizzyApiClient::Resources::Cards

Included in:
Client
Defined in:
lib/fizzy_api_client/resources/cards.rb

Instance Method Summary collapse

Instance Method Details

#card(card_number, account_slug: nil) ⇒ Object



11
12
13
14
15
# File 'lib/fizzy_api_client/resources/cards.rb', line 11

def card(card_number, account_slug: nil)
  slug = ()
  response = connection.get("/#{slug}/cards/#{card_number}")
  response.body
end

#cards(page: nil, auto_paginate: false, account_slug: nil, **filters) ⇒ Object



6
7
8
9
# File 'lib/fizzy_api_client/resources/cards.rb', line 6

def cards(page: nil, auto_paginate: false, account_slug: nil, **filters)
  params = build_card_filters(filters)
  paginate("/cards", params: params, account_slug: , auto_paginate: auto_paginate, page: page)
end

#close_card(card_number, account_slug: nil) ⇒ Object



64
65
66
67
68
# File 'lib/fizzy_api_client/resources/cards.rb', line 64

def close_card(card_number, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/closure")
  response.no_content? ? nil : response.body
end

#create_card(board_id:, title:, description: nil, status: nil, tag_ids: nil, created_at: nil, last_active_at: nil, image: nil, account_slug: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fizzy_api_client/resources/cards.rb', line 17

def create_card(board_id:, title:, description: nil, status: nil, tag_ids: nil,
                created_at: nil, last_active_at: nil, image: nil, account_slug: nil)
  slug = ()

  payload = { title: title }
  payload[:description] = description unless description.nil?
  payload[:status] = status unless status.nil?
  payload[:tag_ids] = tag_ids unless tag_ids.nil?
  payload[:created_at] = created_at unless created_at.nil?
  payload[:last_active_at] = last_active_at unless last_active_at.nil?

  if image
    response = create_card_with_image(slug, board_id, payload, image)
  else
    response = connection.post("/#{slug}/boards/#{board_id}/cards", body: { card: payload })
  end

  response = connection.follow_location(response)
  response.body
end

#delete_card(card_number, account_slug: nil) ⇒ Object



58
59
60
61
62
# File 'lib/fizzy_api_client/resources/cards.rb', line 58

def delete_card(card_number, account_slug: nil)
  slug = ()
  response = connection.delete("/#{slug}/cards/#{card_number}")
  response.no_content? ? nil : response.body
end

#gild_card(card_number, account_slug: nil) ⇒ Object

Makes a card a "golden ticket" (highlighted/pinned card)



124
125
126
127
128
# File 'lib/fizzy_api_client/resources/cards.rb', line 124

def gild_card(card_number, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/goldness")
  response.no_content? ? nil : response.body
end

#postpone_card(card_number, account_slug: nil) ⇒ Object Also known as: not_now_card



76
77
78
79
80
# File 'lib/fizzy_api_client/resources/cards.rb', line 76

def postpone_card(card_number, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/not_now")
  response.no_content? ? nil : response.body
end

#reopen_card(card_number, account_slug: nil) ⇒ Object



70
71
72
73
74
# File 'lib/fizzy_api_client/resources/cards.rb', line 70

def reopen_card(card_number, account_slug: nil)
  slug = ()
  response = connection.delete("/#{slug}/cards/#{card_number}/closure")
  response.no_content? ? nil : response.body
end

#toggle_assignment(card_number, assignee_id:, account_slug: nil) ⇒ Object



97
98
99
100
101
102
# File 'lib/fizzy_api_client/resources/cards.rb', line 97

def toggle_assignment(card_number, assignee_id:, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/assignments",
                             body: { assignee_id: assignee_id })
  response.no_content? ? nil : response.body
end

#toggle_tag(card_number, tag_title:, account_slug: nil) ⇒ Object



104
105
106
107
108
109
# File 'lib/fizzy_api_client/resources/cards.rb', line 104

def toggle_tag(card_number, tag_title:, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/taggings",
                             body: { tag_title: tag_title })
  response.no_content? ? nil : response.body
end

#triage_card(card_number, column_id:, account_slug: nil) ⇒ Object



84
85
86
87
88
89
# File 'lib/fizzy_api_client/resources/cards.rb', line 84

def triage_card(card_number, column_id:, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/triage",
                             body: { column_id: column_id })
  response.no_content? ? nil : response.body
end

#ungild_card(card_number, account_slug: nil) ⇒ Object

Removes "golden ticket" status from a card



131
132
133
134
135
# File 'lib/fizzy_api_client/resources/cards.rb', line 131

def ungild_card(card_number, account_slug: nil)
  slug = ()
  response = connection.delete("/#{slug}/cards/#{card_number}/goldness")
  response.no_content? ? nil : response.body
end

#untriage_card(card_number, account_slug: nil) ⇒ Object



91
92
93
94
95
# File 'lib/fizzy_api_client/resources/cards.rb', line 91

def untriage_card(card_number, account_slug: nil)
  slug = ()
  response = connection.delete("/#{slug}/cards/#{card_number}/triage")
  response.no_content? ? nil : response.body
end

#unwatch_card(card_number, account_slug: nil) ⇒ Object



117
118
119
120
121
# File 'lib/fizzy_api_client/resources/cards.rb', line 117

def unwatch_card(card_number, account_slug: nil)
  slug = ()
  response = connection.delete("/#{slug}/cards/#{card_number}/watch")
  response.no_content? ? nil : response.body
end

#update_card(card_number, title: nil, description: nil, status: nil, tag_ids: nil, last_active_at: nil, image: nil, account_slug: nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fizzy_api_client/resources/cards.rb', line 38

def update_card(card_number, title: nil, description: nil, status: nil, tag_ids: nil,
                last_active_at: nil, image: nil, account_slug: nil)
  slug = ()

  payload = {}
  payload[:title] = title unless title.nil?
  payload[:description] = description unless description.nil?
  payload[:status] = status unless status.nil?
  payload[:tag_ids] = tag_ids unless tag_ids.nil?
  payload[:last_active_at] = last_active_at unless last_active_at.nil?

  if image
    response = update_card_with_image(slug, card_number, payload, image)
  else
    response = connection.put("/#{slug}/cards/#{card_number}", body: { card: payload })
  end

  response.no_content? ? nil : response.body
end

#watch_card(card_number, account_slug: nil) ⇒ Object



111
112
113
114
115
# File 'lib/fizzy_api_client/resources/cards.rb', line 111

def watch_card(card_number, account_slug: nil)
  slug = ()
  response = connection.post("/#{slug}/cards/#{card_number}/watch")
  response.no_content? ? nil : response.body
end