Module: RubyLokaliseApi::Request

Includes:
BaseRequest, Connection
Included in:
Collections::Base, RubyLokaliseApi::Resources::Base
Defined in:
lib/ruby_lokalise_api/request.rb

Constant Summary collapse

PAGINATION_HEADERS =

Lokalise returns pagination info in special headers

%w[x-pagination-total-count x-pagination-page-count x-pagination-limit x-pagination-page].freeze

Constants included from Connection

Connection::BASE_URL

Instance Method Summary collapse

Methods included from Connection

#connection

Methods included from JsonHandler

#custom_dump, #custom_load

Instance Method Details

#delete(path, client, params = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ruby_lokalise_api/request.rb', line 39

def delete(path, client, params = {})
  respond_with(
    # Rubocop tries to replace `delete` with `gsub` but that's a different method here!

    # rubocop:disable Style/CollectionMethods

    connection(client).delete(prepare(path)) do |req|
      # rubocop:enable Style/CollectionMethods

      req.body = custom_dump params
    end,
    client
  )
end

#get(path, client, params = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/ruby_lokalise_api/request.rb', line 11

def get(path, client, params = {})
  respond_with(
    connection(client).get(prepare(path), params),
    client
  )
end

#patch(path, client, params = {}) ⇒ Object



32
33
34
35
36
37
# File 'lib/ruby_lokalise_api/request.rb', line 32

def patch(path, client, params = {})
  respond_with(
    connection(client).patch(prepare(path), params.any? ? custom_dump(params) : nil),
    client
  )
end

#post(path, client, params = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/ruby_lokalise_api/request.rb', line 18

def post(path, client, params = {})
  respond_with(
    connection(client).post(prepare(path), custom_dump(params)),
    client
  )
end

#put(path, client, params = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/ruby_lokalise_api/request.rb', line 25

def put(path, client, params = {})
  respond_with(
    connection(client).put(prepare(path), custom_dump(params)),
    client
  )
end