Sha256: 099f5b39d0f27ddef609fe5afea96408371feeeacd4a4240b4d1f06e0fbacdcb

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

module PortaText
  module Command
    module Api
      # The destinations endpoint.
      # https://github.com/PortaText/docs/wiki/REST-API#api_destinations
      #
      # Author::    Marcelo Gornstein (mailto:marcelog@portatext.com)
      # Copyright:: Copyright (c) 2015 PortaText
      # License::   Apache-2.0
      class Destinations < Base
        def page(page)
          set :page, page
        end

        def sort_by(sort_by, order)
          set :sort_by, sort_by
          set :order, order
        end

        def save_to(file)
          set :accept_file, file
        end

        # rubocop:disable Metrics/MethodLength
        # rubocop:disable Metrics/AbcSize
        def endpoint(_method)
          qs = {}
          unless @args[:page].nil?
            qs['page'] = @args[:page]
            @args.delete :page
          end
          unless @args[:sort_by].nil?
            qs['sort_by'] = @args[:sort_by]
            @args.delete :sort_by
          end
          unless @args[:order].nil?
            qs['order'] = @args[:order]
            @args.delete :order
          end

          return "destinations?#{URI.encode_www_form qs}" unless qs.empty?
          'destinations'
        end
        # rubocop:enable Metrics/AbcSize
        # rubocop:enable Metrics/MethodLength
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
portatext-1.6.1 lib/portatext/command/api/destinations.rb
portatext-1.6.0 lib/portatext/command/api/destinations.rb
portatext-1.5.23 lib/portatext/command/api/destinations.rb
portatext-1.5.22 lib/portatext/command/api/destinations.rb
portatext-1.5.21 lib/portatext/command/api/destinations.rb
portatext-1.5.20 lib/portatext/command/api/destinations.rb
portatext-1.5.19 lib/portatext/command/api/destinations.rb
portatext-1.5.18 lib/portatext/command/api/destinations.rb
portatext-1.5.17 lib/portatext/command/api/destinations.rb
portatext-1.5.16 lib/portatext/command/api/destinations.rb
portatext-1.5.15 lib/portatext/command/api/destinations.rb
portatext-1.5.14 lib/portatext/command/api/destinations.rb
portatext-1.5.13 lib/portatext/command/api/destinations.rb
portatext-1.5.12 lib/portatext/command/api/destinations.rb
portatext-1.5.11 lib/portatext/command/api/destinations.rb
portatext-1.5.10 lib/portatext/command/api/destinations.rb
portatext-1.5.9 lib/portatext/command/api/destinations.rb
portatext-1.5.8 lib/portatext/command/api/destinations.rb
portatext-1.5.7 lib/portatext/command/api/destinations.rb
portatext-1.5.6 lib/portatext/command/api/destinations.rb