Class: Ebay

Inherits:
Object
  • Object
show all
Defined in:
lib/ebayer/get_user_profile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_url, callname, response_encoding, api_version, app_id, user_id) ⇒ Ebay

Returns a new instance of Ebay.



6
7
8
9
10
11
12
13
# File 'lib/ebayer/get_user_profile.rb', line 6

def initialize(open_url, callname, response_encoding, api_version,  app_id, user_id)
  @open_url = open_url
  @callname = callname
  @response_encoding= response_encoding
  @api_version = api_version
  @app_id = app_id
  @user_id = user_id
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def app_id
  @app_id
end

#callnameObject

Returns the value of attribute callname.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def callname
  @callname
end

#open_urlObject

Returns the value of attribute open_url.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def open_url
  @open_url
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def response
  @response
end

#response_encodingObject

Returns the value of attribute response_encoding.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def response_encoding
  @response_encoding
end

#user_idObject

Returns the value of attribute user_id.



3
4
5
# File 'lib/ebayer/get_user_profile.rb', line 3

def user_id
  @user_id
end

Instance Method Details

#request_ebayObject



22
23
24
25
26
# File 'lib/ebayer/get_user_profile.rb', line 22

def request_ebay
  requested_url = self.url_definer
  new_response = HTTParty.get(requested_url)
  @response = self.response_parser(new_response.body)
end

#response_parser(response_content) ⇒ Object



28
29
30
# File 'lib/ebayer/get_user_profile.rb', line 28

def response_parser(response_content)
  Hashie::Mash.new(JSON(response_content))
end

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ebayer/get_user_profile.rb', line 32

def success?
  self.response_content ? (self.response_content["Ack"] == "Success") : (self.response_content["Ack"] == "Failure")
end

#url_definerObject



17
18
19
20
# File 'lib/ebayer/get_user_profile.rb', line 17

def url_definer
  url = @open_url+"?callname=#{@callname}&responseencoding=#{@response_encoding}&appid=#{@app_id}&siteid=0&UserID=#{@user_id}&IncludeSelector=Details&version=#{@api_version}"
  return url
end

#user_informationObject



36
37
38
# File 'lib/ebayer/get_user_profile.rb', line 36

def user_information
  self.request_ebay
end