Class: Cuenote::Api::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/cuenote/api/request.rb

Instance Method Summary collapse

Instance Method Details

#add_command(command, id, params) ⇒ Object



15
16
17
# File 'lib/cuenote/api/request.rb', line 15

def add_command command, id, params
  builder.add_command command, id, params
end

#bodyObject



23
24
25
26
27
28
# File 'lib/cuenote/api/request.rb', line 23

def body
  {
    CCC: "",
    xml: builder.build
  }
end

#builderObject



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

def builder
  @builder ||= Cuenote::Api::XmlBuilder.new
end

#configObject



42
43
44
# File 'lib/cuenote/api/request.rb', line 42

def config
  Cuenote::Api.config
end

#passwordObject



38
39
40
# File 'lib/cuenote/api/request.rb', line 38

def password
  config.password
end

#reqObject



7
8
9
10
11
12
13
# File 'lib/cuenote/api/request.rb', line 7

def req
  req = Net::HTTP::Post.new(uri)
  req.basic_auth user, password
  req.content_type = 'form-data'
  req.body = body
  req
end

#uriObject



30
31
32
# File 'lib/cuenote/api/request.rb', line 30

def uri
  @uri ||= URI(config.endpoint)
end

#userObject



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

def user
  config.user
end