Class: Rubeetup::Request

Inherits:
Object
  • Object
show all
Includes:
RequestsCatalog, Utilities
Defined in:
lib/rubeetup/request.rb

Overview

Represents API requests. Provides for their own validation and execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#blank?, #collection_symbolyzer, #present?, #stringify

Methods included from RequestsCatalog

#is_in_catalog?, #request_multipart, #request_path, #required_options

Constructor Details

#initialize(args = {}) ⇒ Request

Returns a new instance of Request.

Parameters:

  • args (Hash{Symbol=>String}) (defaults to: {})

    holds the request’s data

Options Hash (args):

  • :name (Symbol)

    the full request’s name

  • :options (Hash{Symbol=>String})

    holds the request’s options

  • :http_verb (Symbol)

    the request’s http_verb



47
48
49
50
51
52
53
54
55
# File 'lib/rubeetup/request.rb', line 47

def initialize(args = {})
  @name = args[:name]
  @options = args[:options]
  validate_request
  @http_verb = args[:http_verb]
  @method_path = request_path.call(@options)
  @multipart = request_multipart
  @sender = Rubeetup::RequestSender.new
end

Instance Attribute Details

#http_verbSymbol (readonly)

Returns http_verb the http_verb for the request.

Returns:

  • (Symbol)

    http_verb the http_verb for the request



19
20
21
# File 'lib/rubeetup/request.rb', line 19

def http_verb
  @http_verb
end

#method_pathString (readonly)

Returns method_path the path of the Meetup API resource.

Returns:

  • (String)

    method_path the path of the Meetup API resource



24
25
26
# File 'lib/rubeetup/request.rb', line 24

def method_path
  @method_path
end

#multipartLambda (readonly)

Returns multipart if present it contains the multipart POST logic.

Returns:

  • (Lambda)

    multipart if present it contains the multipart POST logic



39
40
41
# File 'lib/rubeetup/request.rb', line 39

def multipart
  @multipart
end

#nameSymbol (readonly)

Returns name the name of the request as input by the user.

Returns:

  • (Symbol)

    name the name of the request as input by the user



14
15
16
# File 'lib/rubeetup/request.rb', line 14

def name
  @name
end

#optionsHash{Symbol=>String} (readonly)

Returns options holds the request’s options.

Returns:

  • (Hash{Symbol=>String})

    options holds the request’s options



29
30
31
# File 'lib/rubeetup/request.rb', line 29

def options
  @options
end

#senderRubeetup::Sender (readonly)

Returns sender the request’s chosen sender.

Returns:

  • (Rubeetup::Sender)

    sender the request’s chosen sender



34
35
36
# File 'lib/rubeetup/request.rb', line 34

def sender
  @sender
end

Instance Method Details

#executeArray<Rubeetup::ResponseWrapper>

Completes this request

Returns:



61
62
63
# File 'lib/rubeetup/request.rb', line 61

def execute
  sender.get_response(self)
end

#to_sObject

For debugging purposes



68
69
70
71
72
73
74
75
76
# File 'lib/rubeetup/request.rb', line 68

def to_s
  <<-DOC.gsub(/^ {8}/, '')
    \nREQUEST
    name => #{name}
    verb => #{http_verb}
    path => #{method_path}
    options => #{options.inspect}\n
  DOC
end