Class: Crowdin::Web::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/crowdin-api/core/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, method, url, payload = {}) ⇒ Request

Returns a new instance of Request.



10
11
12
13
14
# File 'lib/crowdin-api/core/request.rb', line 10

def initialize(connection, method, url, payload = {})
  @connection = connection[url]
  @method     = method
  @payload    = build_payload(payload)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/crowdin-api/core/request.rb', line 6

def connection
  @connection
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/crowdin-api/core/request.rb', line 7

def method
  @method
end

#payloadObject (readonly)

Returns the value of attribute payload.



8
9
10
# File 'lib/crowdin-api/core/request.rb', line 8

def payload
  @payload
end

Instance Method Details

#deleteObject



28
29
30
# File 'lib/crowdin-api/core/request.rb', line 28

def delete
  connection.delete
end

#delete?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/crowdin-api/core/request.rb', line 24

def delete?
  method.eql?(:delete)
end

#getObject



20
21
22
# File 'lib/crowdin-api/core/request.rb', line 20

def get
  connection.get(prepare_payload(payload[:params]))
end

#get?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/crowdin-api/core/request.rb', line 16

def get?
  method.eql?(:get)
end

#patch?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/crowdin-api/core/request.rb', line 41

def patch?
  method.eql?(:patch)
end

#post?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/crowdin-api/core/request.rb', line 36

def post?
  method.eql?(:post)
end

#process_with_bodyObject Also known as: post, patch, put



32
33
34
# File 'lib/crowdin-api/core/request.rb', line 32

def process_with_body
  connection.send(method, prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response }
end

#put?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/crowdin-api/core/request.rb', line 46

def put?
  method.eql?(:put)
end