Sha256: 90262a81639be73dac34d7d19e8ed584ed9487a0a9cdb82742f00337b86669bc

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

module ChatWork
  module File
    extend EntityMethods

    # Get the list of files associated with the specified chat
    #
    # @param room_id [Integer]
    # @param account_id [Integer]
    #
    # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-files
    # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
    #
    # @return [Array<Hashie::Mash>]
    #
    # @example response format
    #   [
    #     {
    #       "file_id": 3,
    #       "account": {
    #         "account_id": 123,
    #         "name": "Bob",
    #         "avatar_image_url": "https://example.com/ico_avatar.png"
    #       },
    #       "message_id": "22",
    #       "filename": "README.md",
    #       "filesize": 2232,
    #       "upload_time": 1384414750
    #     }
    #   ]
    def self.get(room_id:, account_id:)
      _get("/rooms/#{room_id}/files", account_id: account_id)
    end

    # Get information about the specified file
    #
    # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-files-file_id
    # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
    #
    # @param room_id [Integer]
    # @param file_id [Integer]
    # @param create_download_url [Boolean] whether or not to create a download link.
    #                                      If set to true, download like will be created for 30 seconds
    #
    # @return [Hashie::Mash]
    #
    # @example response format
    #   {
    #     "file_id":3,
    #     "account": {
    #       "account_id":123,
    #       "name":"Bob",
    #       "avatar_image_url": "https://example.com/ico_avatar.png"
    #     },
    #     "message_id": "22",
    #     "filename": "README.md",
    #     "filesize": 2232,
    #     "upload_time": 1384414750
    #   }
    def self.find(room_id:, file_id:, create_download_url: nil)
      _get("/rooms/#{room_id}/files/#{file_id}", create_download_url: boolean_to_integer(create_download_url))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chatwork-0.7.0 lib/chatwork/file.rb
chatwork-0.6.2 lib/chatwork/file.rb
chatwork-0.6.1 lib/chatwork/file.rb