Class: PlayStationNetwork::API
- Inherits:
-
Object
- Object
- PlayStationNetwork::API
- Defined in:
- lib/playstationnetwork/api.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(*options) ⇒ API
constructor
A new instance of API.
-
#post(url, dig_to: [], xml: false) ⇒ Object
response(http.request(request), dig_to) end end.
Constructor Details
#initialize(*options) ⇒ API
Returns a new instance of API.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/playstationnetwork/api.rb', line 57 def initialize(*) raise CONFIG_ERROR unless PlayStationNetwork.valid? @config = PlayStationNetwork.configuration @options = { api_key: config.key, api_secret: config.secret, response_type: 'json' } end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
53 54 55 |
# File 'lib/playstationnetwork/api.rb', line 53 def config @config end |
#options ⇒ Object
Returns the value of attribute options.
53 54 55 |
# File 'lib/playstationnetwork/api.rb', line 53 def @options end |
Instance Method Details
#post(url, dig_to: [], xml: false) ⇒ Object
response(http.request(request), dig_to)
end
end
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/playstationnetwork/api.rb', line 81 def post(url, dig_to: [], xml: false) uri = URI.parse([config.url, url].join) Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https'), verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data() response(http.request(request), dig_to, xml) end end |