exact-target-api 0.0.1

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +41 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +62 -0
  7. data/Rakefile +1 -0
  8. data/exact-target-api.gemspec +22 -0
  9. data/lib/exact-target-api.rb +43 -0
  10. data/lib/exact-target-api/base_object.rb +28 -0
  11. data/lib/exact-target-api/bounce_event.rb +8 -0
  12. data/lib/exact-target-api/campaign.rb +19 -0
  13. data/lib/exact-target-api/click_event.rb +8 -0
  14. data/lib/exact-target-api/client.rb +175 -0
  15. data/lib/exact-target-api/constructor.rb +34 -0
  16. data/lib/exact-target-api/content_area.rb +8 -0
  17. data/lib/exact-target-api/continue.rb +33 -0
  18. data/lib/exact-target-api/continue_rest.rb +24 -0
  19. data/lib/exact-target-api/create_wsdl.rb +53 -0
  20. data/lib/exact-target-api/cud_support.rb +19 -0
  21. data/lib/exact-target-api/cud_support_rest.rb +72 -0
  22. data/lib/exact-target-api/data_extension.rb +226 -0
  23. data/lib/exact-target-api/delete.rb +38 -0
  24. data/lib/exact-target-api/delete_rest.rb +18 -0
  25. data/lib/exact-target-api/describe.rb +25 -0
  26. data/lib/exact-target-api/email.rb +8 -0
  27. data/lib/exact-target-api/folder.rb +8 -0
  28. data/lib/exact-target-api/get.rb +64 -0
  29. data/lib/exact-target-api/get_rest.rb +25 -0
  30. data/lib/exact-target-api/get_support.rb +23 -0
  31. data/lib/exact-target-api/get_support_rest.rb +86 -0
  32. data/lib/exact-target-api/list.rb +68 -0
  33. data/lib/exact-target-api/list_subscriber.rb +10 -0
  34. data/lib/exact-target-api/open_event.rb +8 -0
  35. data/lib/exact-target-api/patch.rb +39 -0
  36. data/lib/exact-target-api/patch_rest.rb +19 -0
  37. data/lib/exact-target-api/post.rb +34 -0
  38. data/lib/exact-target-api/post_rest.rb +19 -0
  39. data/lib/exact-target-api/sent_event.rb +8 -0
  40. data/lib/exact-target-api/subscriber.rb +81 -0
  41. data/lib/exact-target-api/triggered_send.rb +15 -0
  42. data/lib/exact-target-api/unsub_event.rb +8 -0
  43. data/lib/exact-target-api/version.rb +3 -0
  44. metadata +113 -0
@@ -0,0 +1,34 @@
1
+ module ET
2
+ class Post < ET::Constructor
3
+ def initialize(client, objType, props = nil)
4
+ @results = []
5
+
6
+ begin
7
+ client.refreshToken
8
+
9
+ obj = {
10
+ 'Objects' => props,
11
+ attributes!: {'Objects' => {'xsi:type' => 'tns:' + objType}}
12
+ }
13
+
14
+ response = client.auth.call(:create, message: obj)
15
+
16
+ ensure
17
+ super(response)
18
+ if @status
19
+ if @body[:create_response][:overall_status] != "OK"
20
+ @status = false
21
+ end
22
+ #@results = @body[:create_response][:results]
23
+ if !@body[:create_response][:results].nil?
24
+ if !@body[:create_response][:results].is_a? Hash
25
+ @results = @results + @body[:create_response][:results]
26
+ else
27
+ @results.push(@body[:create_response][:results])
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ module ET
2
+ class PostRest < ET::Constructor
3
+ def initialize(authStub, endpoint, payload)
4
+ authStub.refreshToken
5
+
6
+ qs = {"access_token" => authStub.authToken}
7
+ uri = URI.parse(endpoint)
8
+ uri.query = URI.encode_www_form(qs)
9
+ http = Net::HTTP.new(uri.host, uri.port)
10
+ http.use_ssl = true
11
+ request = Net::HTTP::Post.new(uri.request_uri)
12
+ request.body = payload.to_json
13
+ request.add_field "Content-Type", "application/json"
14
+ requestResponse = http.request(request)
15
+
16
+ super(requestResponse, true)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module ET
2
+ class SentEvent < ET::GetSupport
3
+ def initialize
4
+ super
5
+ @obj = 'SentEvent'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,81 @@
1
+ module ET
2
+ class Subscriber < ET::CUDSupport
3
+ attr_reader :code, :message, :status, :email, :results
4
+
5
+ def initialize(client, list_id = nil)
6
+ super()
7
+ @client = client
8
+ @list_id = list_id
9
+ @obj = 'Subscriber'
10
+ end
11
+
12
+ def create(params = {})
13
+ stringify_keys!(params)
14
+
15
+ email = params.delete('email')
16
+ raise("Please provide email") if email.blank?
17
+
18
+ list_id = if params['list']
19
+ params.delete('list').id
20
+ elsif params['list_id']
21
+ params.delete('list_id')
22
+ elsif @list_id
23
+ @list_id
24
+ end
25
+
26
+ props = {'EmailAddress' => email}
27
+ props['SubscriberKey'] = params.delete('SubscriberKey') if params['SubscriberKey']
28
+
29
+ props['Lists'] = [{'ID' => list_id.to_s}] if list_id
30
+
31
+ if params.count > 0
32
+ props['Attributes'] = params.map do |k, v|
33
+ {'Name' => k.to_s, 'Value' => v}
34
+ end
35
+ end
36
+
37
+ res = post(props)
38
+ if assign_values(res)
39
+ @email = email
40
+ @list_id = list_id
41
+ end
42
+
43
+ self
44
+ end
45
+
46
+ def find(email)
47
+ @email = email
48
+
49
+ props = ["SubscriberKey", "EmailAddress", "Status"]
50
+ filter = {'Property' => 'SubscriberKey', 'SimpleOperator' => 'equals', 'Value' => email}
51
+
52
+ res = get(props, filter)
53
+ if assign_values(res)
54
+ @email = email
55
+ end
56
+
57
+ self
58
+ end
59
+
60
+ def update(params)
61
+ params.merge!('EmailAddress' => @email)
62
+
63
+ # TODO ...
64
+
65
+ end
66
+
67
+
68
+ private
69
+
70
+ def assign_values(res)
71
+ @code = res.code.to_i
72
+ @message = res.message.to_s
73
+ @status = res.status
74
+ @results = res.results
75
+
76
+ res.status
77
+ end
78
+
79
+
80
+ end
81
+ end
@@ -0,0 +1,15 @@
1
+ module ET
2
+ class TriggeredSend < ET::CUDSupport
3
+ attr_accessor :subscribers
4
+
5
+ def initialize
6
+ super
7
+ @obj = 'TriggeredSendDefinition'
8
+ end
9
+
10
+ def send
11
+ @tscall = {"TriggeredSendDefinition" => @props, "Subscribers" => @subscribers}
12
+ ET::Post.new(@authStub, "TriggeredSend", @tscall)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module ET
2
+ class UnsubEvent < ET::GetSupport
3
+ def initialize
4
+ super
5
+ @obj = 'UnsubEvent'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module ET
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exact-target-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Shapiotko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: jwt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.8
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.8
41
+ description: ExactTarget API wrapper
42
+ email:
43
+ - thousandsofthem@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - exact-target-api.gemspec
55
+ - lib/exact-target-api.rb
56
+ - lib/exact-target-api/base_object.rb
57
+ - lib/exact-target-api/bounce_event.rb
58
+ - lib/exact-target-api/campaign.rb
59
+ - lib/exact-target-api/click_event.rb
60
+ - lib/exact-target-api/client.rb
61
+ - lib/exact-target-api/constructor.rb
62
+ - lib/exact-target-api/content_area.rb
63
+ - lib/exact-target-api/continue.rb
64
+ - lib/exact-target-api/continue_rest.rb
65
+ - lib/exact-target-api/create_wsdl.rb
66
+ - lib/exact-target-api/cud_support.rb
67
+ - lib/exact-target-api/cud_support_rest.rb
68
+ - lib/exact-target-api/data_extension.rb
69
+ - lib/exact-target-api/delete.rb
70
+ - lib/exact-target-api/delete_rest.rb
71
+ - lib/exact-target-api/describe.rb
72
+ - lib/exact-target-api/email.rb
73
+ - lib/exact-target-api/folder.rb
74
+ - lib/exact-target-api/get.rb
75
+ - lib/exact-target-api/get_rest.rb
76
+ - lib/exact-target-api/get_support.rb
77
+ - lib/exact-target-api/get_support_rest.rb
78
+ - lib/exact-target-api/list.rb
79
+ - lib/exact-target-api/list_subscriber.rb
80
+ - lib/exact-target-api/open_event.rb
81
+ - lib/exact-target-api/patch.rb
82
+ - lib/exact-target-api/patch_rest.rb
83
+ - lib/exact-target-api/post.rb
84
+ - lib/exact-target-api/post_rest.rb
85
+ - lib/exact-target-api/sent_event.rb
86
+ - lib/exact-target-api/subscriber.rb
87
+ - lib/exact-target-api/triggered_send.rb
88
+ - lib/exact-target-api/unsub_event.rb
89
+ - lib/exact-target-api/version.rb
90
+ homepage: https://github.com/BriteVerify/exact-target-api
91
+ licenses: []
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.0
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: ExactTarget API wrapper
113
+ test_files: []