Class: Click2mail
- Inherits:
-
Object
- Object
- Click2mail
- Defined in:
- lib/click2mail.rb
Instance Method Summary collapse
- #add_address_list(value) ⇒ Object
-
#add_adress_list_to_buider(id, id_addr_list) ⇒ Object
<addresList> <addresses> <name> <organization> <address1> <address2> <city> <state> <postalCode> <country> <addresses> </addresList>.
-
#add_builder ⇒ Object
create a builder.
- #add_doc_to_builder(id, id_doc) ⇒ Object
-
#add_document(file) ⇒ Object
files (documents (pdf) and images).
- #add_image(file) ⇒ Object
- #build_builder(id) ⇒ Object
- #builder_proof(id) ⇒ Object
- #delete_adress_list(id) ⇒ Object
- #documents ⇒ Object
- #get_adress_list(id) ⇒ Object
-
#get_all_address_lists ⇒ Object
Adresses List.
-
#get_status_mailing(id) ⇒ Object
return mailing status AWAITING PRODUCTION The order was built and successfully checked out of the cart.
-
#initialize(u, p, type) ⇒ Click2mail
constructor
A new instance of Click2mail.
- #proprerties_builder(id, text, uri_image) ⇒ Object
- #return_adress_builder(id, name, organization, address1, address2, city, state, postal_code, country) ⇒ Object
- #select_product(id, product) ⇒ Object
- #select_template(id) ⇒ Object
Constructor Details
#initialize(u, p, type) ⇒ Click2mail
Returns a new instance of Click2mail.
5 6 7 8 9 |
# File 'lib/click2mail.rb', line 5 def initialize(u, p,type) @auth = {:username => u, :password => p} type == "test"? @uri = 'stage.rest.click2mail.com/v1' : @uri = 'rest.click2mail.com/v1' @uri = "https://#{@auth[:username]}:#{@auth[:password]}@#{@uri}" end |
Instance Method Details
#add_address_list(value) ⇒ Object
18 19 20 |
# File 'lib/click2mail.rb', line 18 def add_address_list(value) RestClient.post("#{@uri}/addressLists",value,{:accept => :xml, :content_type => :xml}) end |
#add_adress_list_to_buider(id, id_addr_list) ⇒ Object
<addresList> <addresses> <name> <organization> <address1> <address2> <city> <state> <postalCode> <country> <addresses> </addresList>
64 65 66 |
# File 'lib/click2mail.rb', line 64 def add_adress_list_to_buider(id,id_addr_list) RestClient.put("#{@uri}/mailingBuilders/#{id}/addressList","id=#{id_addr_list}", :content_type => 'application/x-www-form-urlencoded' ) end |
#add_builder ⇒ Object
create a builder
47 48 49 |
# File 'lib/click2mail.rb', line 47 def add_builder RestClient.post("#{@uri}/mailingBuilders",nil) end |
#add_doc_to_builder(id, id_doc) ⇒ Object
92 93 94 |
# File 'lib/click2mail.rb', line 92 def add_doc_to_builder(id,id_doc) RestClient.put("#{@uri}/mailingBuilders/#{id}/document","id=#{id_doc}", :content_type => 'application/x-www-form-urlencoded' ) end |
#add_document(file) ⇒ Object
files (documents (pdf) and images)
103 104 105 |
# File 'lib/click2mail.rb', line 103 def add_document(file) RestClient.post "#{@uri}/documents/",file,:content_type => 'application/pdf' end |
#add_image(file) ⇒ Object
111 112 113 |
# File 'lib/click2mail.rb', line 111 def add_image(file) RestClient.post "#{@uri}/images/",file,:content_type => 'application/octet-stream' end |
#build_builder(id) ⇒ Object
51 52 53 |
# File 'lib/click2mail.rb', line 51 def build_builder(id) RestClient.post("#{@uri}/mailingBuilders/#{id}/build/",nil) end |
#builder_proof(id) ⇒ Object
55 56 57 |
# File 'lib/click2mail.rb', line 55 def builder_proof(id) RestClient.get("#{@uri}/mailingBuilders/#{id}/proofs/1",:accept => 'application/pdf' ) end |
#delete_adress_list(id) ⇒ Object
26 27 28 |
# File 'lib/click2mail.rb', line 26 def delete_adress_list(id) RestClient.delete("#{@uri}/addressLists/#{id}") end |
#documents ⇒ Object
107 108 109 |
# File 'lib/click2mail.rb', line 107 def documents RestClient.get("#{@uri}/documents") end |
#get_adress_list(id) ⇒ Object
22 23 24 |
# File 'lib/click2mail.rb', line 22 def get_adress_list(id) RestClient.get("#{@uri}/addressLists/#{id}") end |
#get_all_address_lists ⇒ Object
Adresses List
14 15 16 |
# File 'lib/click2mail.rb', line 14 def get_all_address_lists RestClient.get("#{@uri}/addressLists") end |
#get_status_mailing(id) ⇒ Object
return mailing status AWAITING PRODUCTION The order was built and successfully checked out of the cart. PENDING PAYMENT The order was built, but there were insufficient credits to check it out of the cart. ERROR An unforeseen error condition. Please check the <statusMessage> tag for details.
38 39 40 |
# File 'lib/click2mail.rb', line 38 def get_status_mailing(id) RestClient.get("#{@uri}/mailings/#{id}") end |
#proprerties_builder(id, text, uri_image) ⇒ Object
71 72 73 |
# File 'lib/click2mail.rb', line 71 def proprerties_builder(id,text,uri_image) RestClient.put("#{@uri}/mailingBuilders/#{id}/properties","text=#{text}&image=#{uri_image}", :content_type => 'application/x-www-form-urlencoded' ) end |
#return_adress_builder(id, name, organization, address1, address2, city, state, postal_code, country) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/click2mail.rb', line 75 def return_adress_builder(id,name,organization,address1,address2,city,state,postal_code,country) = {:params => {:name => name, :organization => organization , :address1 => address1 , :address2 => address2, :city => city , :state => state , :postalCode => postal_code , :country => country}, :basic_auth => @auth } RestClient.put("#{@uri}/mailingBuilders/#{id}/returnAddress",) end |
#select_product(id, product) ⇒ Object
88 89 90 |
# File 'lib/click2mail.rb', line 88 def select_product(id,product) RestClient.put("#{@uri}/mailingBuilders/#{id}","sku=#{product}", :content_type => 'application/x-www-form-urlencoded' ) end |
#select_template(id) ⇒ Object
96 97 98 |
# File 'lib/click2mail.rb', line 96 def select_template(id) RestClient.put("#{@uri}/mailingBuilders/#{id}/template","name=Easy+Letter+Sender+--+Postcard", :content_type => 'application/x-www-form-urlencoded' ) end |