Sha256: 3ffaecc03aac1c8559d4616f88caf4f124798304ee97408b7acf59924ff03a99

Contents?: true

Size: 729 Bytes

Versions: 4

Compression:

Stored size: 729 Bytes

Contents

class FutureLink
  attr_reader :url, :title

  def initialize(url:, title: url)
    @url = url
    @title = title
  end

  def to_request_params
    {
      url: url,
      title: title,
    }
  end

  def add_to_board(client:, remote_board:)
    client.authorize_if_no_bearer_token!
    response = client.faraday.post(
      "/v2/boards/#{remote_board.id}/links",
      # this needs to be a array with hashes => [{name, filesize}]
      JSON.pretty_generate([to_request_params]),
      client.auth_headers.merge('Content-Type' => 'application/json')
    )
    client.ensure_ok_status!(response)
    file_item = JSON.parse(response.body, symbolize_names: true).first
    remote_board.items << RemoteLink.new(file_item)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wetransfer-0.9.0.beta3 lib/we_transfer_client/future_link.rb
wetransfer-0.9.0.beta2 lib/we_transfer_client/future_link.rb
wetransfer-0.9.0.beta1 lib/we_transfer_client/future_link.rb
wetransfer-0.9.0.beta lib/we_transfer_client/future_link.rb