Sha256: 3c63f9c97e82b46fd8a5437d1b771134625aa9a083238fbd7c510c0bb44fed2e

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

module Nimbu
  module Endpoints
    class Channels::Entries < Endpoint
      def list(*args, &block)
        arguments(args, required: [:channel_id])

        response = get_request("/channels/#{channel_id}/entries", arguments.params)

        if block_given?
          response.each(&block)
        else
          response
        end
      end
      alias_method :all, :list

      def first(*args)
        arguments(args, required: [:channel_id])

        get_request("/channels/#{channel_id}/entries", arguments.params.merge(limit: 1)).first
      end

      def list_deleted(*args)
        arguments(args, required: [:channel_id])

        get_request("/channels/#{channel_id}/entries/deleted", arguments.params)
      end
      alias_method :list_removed, :list_deleted

      def count(*args)
        arguments(args, required: [:channel_id])

        get_request("/channels/#{channel_id}/entries/count", arguments.params)
      end

      def get(*args)
        arguments(args, required: [:channel_id, :entry_id])

        get_request("/channels/#{channel_id}/entries/#{entry_id}", arguments.params)
      end
      alias_method :find, :get

      def create(*args)
        arguments(args, required: [:channel_id])

        post_request("/channels/#{channel_id}/entries", arguments.params, with_attachments: true)
      end

      def update(*args)
        arguments(args, required: [:channel_id, :entry_id])

        patch_request("/channels/#{channel_id}/entries/#{entry_id}", arguments.params, with_attachments: true)
      end
      alias_method :edit, :update

      def delete(*args)
        arguments(args, required: [:channel_id, :entry_id])

        delete_request("/channels/#{channel_id}/entries/#{entry_id}", arguments.params)
      end
      alias_method :remove, :delete
    end # Channel::Entries
  end # Endpoints
end # Nimbu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nimbu-api-0.5.0 lib/nimbu-api/endpoints/channels/entries.rb