Class: HatenablogPublisher::Api
- Inherits:
-
Object
- Object
- HatenablogPublisher::Api
- Defined in:
- lib/hatenablog_publisher/api.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(site) ⇒ Api
constructor
A new instance of Api.
- #request(path, body, method = :post) ⇒ Object
Constructor Details
#initialize(site) ⇒ Api
Returns a new instance of Api.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hatenablog_publisher/api.rb', line 8 def initialize(site) @site = site @header = { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' } consumer = OAuth::Consumer.new( ENV['HATENABLOG_CONSUMER_KEY'], ENV['HATENABLOG_CONSUMER_SECRET'], site: site, timeout: 300 ) @client = OAuth::AccessToken.new( consumer, ENV['HATENABLOG_ACCESS_TOKEN'], ENV['HATENABLOG_ACCESS_TOKEN_SECRET'] ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/hatenablog_publisher/api.rb', line 6 def client @client end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
6 7 8 |
# File 'lib/hatenablog_publisher/api.rb', line 6 def header @header end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/hatenablog_publisher/api.rb', line 6 def site @site end |
Instance Method Details
#request(path, body, method = :post) ⇒ Object
30 31 32 |
# File 'lib/hatenablog_publisher/api.rb', line 30 def request(path, body, method = :post) @client.request(method, path, body, @header) end |