click2mail 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/click2mail.rb +123 -0
- metadata +45 -0
data/lib/click2mail.rb
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
require 'rest_client'
|
|
2
|
+
|
|
3
|
+
class Click2mail
|
|
4
|
+
|
|
5
|
+
def initialize(u, p,type)
|
|
6
|
+
@auth = {:username => u, :password => p}
|
|
7
|
+
type == "test"? @uri = 'stage.rest.click2mail.com/v1' : @uri = 'rest.click2mail.com/v1'
|
|
8
|
+
@uri = "https://#{@auth[:username]}:#{@auth[:password]}@#{@uri}"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
###############
|
|
12
|
+
### Adresses List
|
|
13
|
+
###############
|
|
14
|
+
def get_all_address_lists
|
|
15
|
+
RestClient.get("#{@uri}/addressLists")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def add_address_list(value)
|
|
19
|
+
RestClient.post("#{@uri}/addressLists",value,{:accept => :xml, :content_type => :xml})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get_adress_list(id)
|
|
23
|
+
RestClient.get("#{@uri}/addressLists/#{id}")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_adress_list(id)
|
|
27
|
+
RestClient.delete("#{@uri}/addressLists/#{id}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#################
|
|
31
|
+
### mailing
|
|
32
|
+
#################
|
|
33
|
+
|
|
34
|
+
#return mailing status
|
|
35
|
+
# AWAITING PRODUCTION The order was built and successfully checked out of the cart.
|
|
36
|
+
# PENDING PAYMENT The order was built, but there were insufficient credits to check it out of the cart.
|
|
37
|
+
# ERROR An unforeseen error condition. Please check the <statusMessage> tag for details.
|
|
38
|
+
def get_status_mailing(id)
|
|
39
|
+
RestClient.get("#{@uri}/mailings/#{id}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#################
|
|
43
|
+
### Builders
|
|
44
|
+
#################
|
|
45
|
+
|
|
46
|
+
#create a builder
|
|
47
|
+
def add_builder
|
|
48
|
+
RestClient.post("#{@uri}/mailingBuilders",nil)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def build_builder(id)
|
|
52
|
+
RestClient.post("#{@uri}/mailingBuilders/#{id}/build/",nil)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def builder_proof(id)
|
|
56
|
+
RestClient.get("#{@uri}/mailingBuilders/#{id}/proofs/1",:accept => 'application/pdf' )
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#<addresList>
|
|
60
|
+
#<addresses>
|
|
61
|
+
#<name> <organization> <address1> <address2> <city> <state> <postalCode> <country>
|
|
62
|
+
#<addresses>
|
|
63
|
+
#</addresList>
|
|
64
|
+
def add_adress_list_to_buider(id,id_addr_list)
|
|
65
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}/addressList","id=#{id_addr_list}", :content_type => 'application/x-www-form-urlencoded' )
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
#@id builder
|
|
69
|
+
#@text (the text for the back of the card)
|
|
70
|
+
#@uri_image (the uri of the uploaded image).
|
|
71
|
+
def proprerties_builder(id,text,uri_image)
|
|
72
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}/properties","text=#{text}&image=#{uri_image}", :content_type => 'application/x-www-form-urlencoded' )
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def return_adress_builder(id,name,organization,address1,address2,city,state,postal_code,country)
|
|
76
|
+
options = {:params => {:name => name,
|
|
77
|
+
:organization => organization ,
|
|
78
|
+
:address1 => address1 ,
|
|
79
|
+
:address2 => address2,
|
|
80
|
+
:city => city ,
|
|
81
|
+
:state => state ,
|
|
82
|
+
:postalCode => postal_code ,
|
|
83
|
+
:country => country}, :basic_auth => @auth }
|
|
84
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}/returnAddress",options)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def select_product(id,product)
|
|
89
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}","sku=#{product}", :content_type => 'application/x-www-form-urlencoded' )
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def add_doc_to_builder(id,id_doc)
|
|
93
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}/document","id=#{id_doc}", :content_type => 'application/x-www-form-urlencoded' )
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def select_template(id)
|
|
97
|
+
RestClient.put("#{@uri}/mailingBuilders/#{id}/template","name=Easy+Letter+Sender+--+Postcard", :content_type => 'application/x-www-form-urlencoded' )
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
###########
|
|
101
|
+
# files (documents (pdf) and images)
|
|
102
|
+
###############
|
|
103
|
+
def add_document(file)
|
|
104
|
+
RestClient.post "#{@uri}/documents/",file,:content_type => 'application/pdf'
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def documents
|
|
108
|
+
RestClient.get("#{@uri}/documents")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def add_image(file)
|
|
112
|
+
RestClient.post "#{@uri}/images/",file,:content_type => 'application/octet-stream'
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: click2mail
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Bolo Michelin
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-05-21 00:00:00.000000000Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Ruby wrapper for the Click2Mail REST API
|
|
15
|
+
email: bolo@lordalexworks.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/click2mail.rb
|
|
21
|
+
homepage: http://rubygems.org/gems/click2mail
|
|
22
|
+
licenses: []
|
|
23
|
+
post_install_message:
|
|
24
|
+
rdoc_options: []
|
|
25
|
+
require_paths:
|
|
26
|
+
- lib
|
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
none: false
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 1.8.15
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 3
|
|
44
|
+
summary: Ruby wrapper for the Click2Mail REST API
|
|
45
|
+
test_files: []
|