Class: AWeber::Base
- Inherits:
-
Object
- Object
- AWeber::Base
- Defined in:
- lib/aweber/base.rb
Class Method Summary collapse
-
.authorize_with_authorization_code(auth_code) ⇒ Object
Authorize an app with an auth code from 1.0/oauth/authorize_app/app_id.
Instance Method Summary collapse
- #account ⇒ Object
- #delete(uri) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize(oauth) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #path ⇒ Object
- #post(uri, body = {}) ⇒ Object
- #put(uri, body = {}) ⇒ Object
Constructor Details
#initialize(oauth) ⇒ Base
Returns a new instance of Base.
4 5 6 |
# File 'lib/aweber/base.rb', line 4 def initialize(oauth) @oauth = oauth end |
Class Method Details
.authorize_with_authorization_code(auth_code) ⇒ Object
Authorize an app with an auth code from 1.0/oauth/authorize_app/app_id
/authorize_app to be used for authorization.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/aweber/base.rb', line 43 def self.(auth_code) consumer_token, consumer_secret, request_token, request_secret, verifier = auth_code.split('|') oauth = AWeber::OAuth.new(consumer_token, consumer_secret) request_hash = {:oauth_token => request_token, :oauth_token_secret => request_secret} request = ::OAuth::RequestToken.from_hash(oauth.consumer, request_hash) oauth.request_token = request oauth.(verifier) self.new(oauth) end |
Instance Method Details
#account ⇒ Object
8 9 10 |
# File 'lib/aweber/base.rb', line 8 def account accounts.first.last end |
#delete(uri) ⇒ Object
18 19 20 |
# File 'lib/aweber/base.rb', line 18 def delete(uri) oauth.delete((uri)) end |
#get(uri) ⇒ Object
12 13 14 15 16 |
# File 'lib/aweber/base.rb', line 12 def get(uri) response = oauth.get((uri)) handle_errors(response, uri) parse(response) if response end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/aweber/base.rb', line 34 def inspect "#<AWeber::Base />" end |
#path ⇒ Object
30 31 32 |
# File 'lib/aweber/base.rb', line 30 def path "" end |
#post(uri, body = {}) ⇒ Object
22 23 24 |
# File 'lib/aweber/base.rb', line 22 def post(uri, body={}) oauth.post((uri), body) end |
#put(uri, body = {}) ⇒ Object
26 27 28 |
# File 'lib/aweber/base.rb', line 26 def put(uri, body={}) oauth.put(uri, body.to_json, {"Content-Type" => "application/json"}) end |