Class: Rodzilla::Resource::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rodzilla/resource/base.rb

Direct Known Subclasses

Bug, Bugzilla, Classification, Group, Product, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, username, password, format = :json) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
13
# File 'lib/rodzilla/resource/base.rb', line 6

def initialize(base_url, username, password, format=:json)
  @base_url = base_url
  @username = username
  @password = password
  @format = format

  setup_service(format)
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/rodzilla/resource/base.rb', line 4

def base_url
  @base_url
end

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/rodzilla/resource/base.rb', line 4

def format
  @format
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/rodzilla/resource/base.rb', line 4

def password
  @password
end

#serviceObject

Returns the value of attribute service.



4
5
6
# File 'lib/rodzilla/resource/base.rb', line 4

def service
  @service
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/rodzilla/resource/base.rb', line 4

def username
  @username
end

Instance Method Details

#raw_http_request(http_method, url, options = {}) ⇒ Object

Makes a GET request to the service endpoint and checks if the return status is 200



21
22
23
# File 'lib/rodzilla/resource/base.rb', line 21

def raw_http_request(http_method, url, options={})
  @service.send_raw_request(http_method, url, options)
end

#rpc_call(rpc_method_name, params = {}, http_method = :post) ⇒ Object



15
16
17
# File 'lib/rodzilla/resource/base.rb', line 15

def rpc_call(rpc_method_name, params={}, http_method=:post)
  service.send_request!( get_resource_rpc_method_name(rpc_method_name), params, http_method)
end