Module: FizzyApiClient::Resources::Comments

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

Instance Method Summary collapse

Instance Method Details

#comment(card_number, comment_id, account_slug: nil) ⇒ Object



12
13
14
15
16
# File 'lib/fizzy_api_client/resources/comments.rb', line 12

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

#comments(card_number, account_slug: nil) ⇒ Object



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

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

#create_comment(card_number, body:, created_at: nil, account_slug: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fizzy_api_client/resources/comments.rb', line 18

def create_comment(card_number, body:, created_at: nil, account_slug: nil)
  slug = ()

  payload = { body: body }
  payload[:created_at] = created_at unless created_at.nil?

  response = connection.post("/#{slug}/cards/#{card_number}/comments",
                             body: { comment: payload })
  response = connection.follow_location(response)
  response.body
end

#delete_comment(card_number, comment_id, account_slug: nil) ⇒ Object



38
39
40
41
42
# File 'lib/fizzy_api_client/resources/comments.rb', line 38

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

#update_comment(card_number, comment_id, body:, account_slug: nil) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/fizzy_api_client/resources/comments.rb', line 30

def update_comment(card_number, comment_id, body:, account_slug: nil)
  slug = ()

  response = connection.put("/#{slug}/cards/#{card_number}/comments/#{comment_id}",
                            body: { comment: { body: body } })
  response.no_content? ? nil : response.body
end