Class: Officepod::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Authentication, Helper, Storage
Defined in:
lib/officepod.rb

Instance Method Summary collapse

Methods included from Storage

#storage_auth_list

Methods included from Helper

#body_empty?, #command_empty?, #unsupported_command?, #validates_body, #validates_command

Methods included from Authentication

#get_cookie, #login, #logout

Constructor Details

#initialize(command = nil, body = {}, cookie = "") ⇒ Base

Returns a new instance of Base.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/officepod.rb', line 21

def initialize(command=nil, body={}, cookie="")
  options = {
    headers: {
      "User-Agent" => "Gate4Mobile",
      "Content-Type" => "application/x-www-form-urlencoded",
      "Accept" => "application/json"
    }
  }

  end_point = "/server/request.php"

  self.instance_variable_set("@options", options)
  self.instance_variable_set("@end_point", end_point)
  self.instance_variable_set("@command", command)
  @options[:body] = body unless body.empty?
  @options[:headers]["Cookie"] = cookie unless cookie.empty?

  validates_command
end

Instance Method Details

#operateObject



41
42
43
# File 'lib/officepod.rb', line 41

def operate
  send(@command)
end