Class: ChimpRewriter
- Inherits:
-
Object
- Object
- ChimpRewriter
- Includes:
- HTTParty
- Defined in:
- lib/chimp_rewriter.rb,
lib/chimp_rewriter/version.rb
Defined Under Namespace
Classes: ChimpRewriterError
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
Instance Method Summary collapse
- #authentication_params ⇒ Object
- #chimp_rewrite(text, options = {}) ⇒ Object
- #create_spin(text, options = {}) ⇒ Object
-
#initialize(email, app_id, api_key) ⇒ ChimpRewriter
constructor
A new instance of ChimpRewriter.
- #statistics ⇒ Object
Constructor Details
#initialize(email, app_id, api_key) ⇒ ChimpRewriter
Returns a new instance of ChimpRewriter.
13 14 15 16 17 |
# File 'lib/chimp_rewriter.rb', line 13 def initialize email, app_id, api_key @email = email @app_id = app_id @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/chimp_rewriter.rb', line 11 def api_key @api_key end |
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
11 12 13 |
# File 'lib/chimp_rewriter.rb', line 11 def app_id @app_id end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/chimp_rewriter.rb', line 11 def email @email end |
Instance Method Details
#authentication_params ⇒ Object
19 20 21 |
# File 'lib/chimp_rewriter.rb', line 19 def authentication_params {email: email, aid: app_id, apikey: api_key} end |
#chimp_rewrite(text, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/chimp_rewriter.rb', line 32 def chimp_rewrite text, = {} response_hash = make_request "ChimpRewrite", .merge(text: text) response_hash["output"] end |
#create_spin(text, options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/chimp_rewriter.rb', line 37 def create_spin text, = {} response_hash = make_request "CreateSpin", .merge(text: text) response_hash["output"] end |
#statistics ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/chimp_rewriter.rb', line 23 def statistics response_hash = make_request "Statistics" response_hash.delete "error" response_hash.each_pair do |key, value| response_hash[key] = value.to_i if value.to_i.to_s == value end OpenStruct.new response_hash end |