Class: Eztexting::Credits

Inherits:
Base
  • Object
show all
Defined in:
lib/eztexting/credits.rb

Class Method Summary collapse

Methods inherited from Base

do_post, processed_reponse

Class Method Details

.balanceArray

Check the balance of credits left on your account



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/eztexting/credits.rb', line 6

def self.balance
  location = "/credits/check/"
  
  response = self.do_post(location,{})  
  response_result = if response.to_i > 0
    "The amount of plan and additional credits available"
  elsif response == -1
    "Invalid user and/or password or API is not allowed for your account"
  else
    "Unknown error (please contact our support dept.)"
  end
  
  return self.processed_reponse(response_result,response)
end

.purchase(opts = {}) ⇒ Array

Purchase more credits for your account



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/eztexting/credits.rb', line 24

def self.purchase(opts={})
  location = "/credits/buy/"
  options = {
    :credits => opts[:credits],
    :firstname => opts[:first_name],
    :lastname => opts[:last_name],
    :address => opts[:address], 
    :city => opts[:city], 
    :state => opts[:state], 
    :zip => opts[:zip], 
    :country => opts[:country], 
    :type => opts[:cc_type], 
    :ccnumber => opts[:cc_number],
    :cccode => opts[:cc_verification_code], 
    :expm => opts[:cc_expiration_month], 
    :expy => opts[:cc_expiration_year]
  }
  
  response = self.do_post(location,options)
  response_result = self.process(response)

  return self.processed_reponse(response_result,response)
end