platformx 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ecc6db65af06220ba1cd3b0f66f47c1633ea305
4
- data.tar.gz: db02e2eeea2580171a5164f6f0e1e6a604bcc259
3
+ metadata.gz: 11401e09149022fde8fdb14a2eabc94be4df5917
4
+ data.tar.gz: e1699f7712a4cb2f7bd39e9c204081dc1eab55b2
5
5
  SHA512:
6
- metadata.gz: 1f3ce2902a20dec1c02b09cccc96216a9c97a5bd51b63874131f47d32d7345b8aa72526aab387c095c6eb9104ca920ae5bf0c603d8c4625529e184513c9695df
7
- data.tar.gz: 9aa30f3e26d87900950f1e6094fcdf475c8eb39eeca51009c1dfe2e787053d65d7ac8e4b856218def26f6a92a80ba50c6f01800d0b9c79b0088d31828408ba63
6
+ metadata.gz: 0d54c6c7754ba961f3b78012e9c50db730ff6a941fa49d748b7521212a639fd7de4264b7f0f1e35cd6130f020007ffd2f663aab02a93390b65a8aa757e27bb52
7
+ data.tar.gz: 6ef11e9a97363506e57ed0c559300739896bc922a7ddfff6d0d140a1e5403e373503ff9094dc193d82e76f46478ea111cc0a8e43c1b2639d23c19279cbeebd19
@@ -1,5 +1,4 @@
1
1
  require "platformx/version"
2
- require "platformx/configuration"
3
2
  require "platformx/auth"
4
3
  require "platformx/form"
5
4
  require "platformx/layout"
@@ -7,11 +6,10 @@ require "platformx/date"
7
6
  require "platformx/notify"
8
7
  require "platformx/mail"
9
8
  require "platformx/stripe"
10
- require "platformx/google_map"
11
- require "platformx/instagram"
12
9
  require "platformx/faker"
13
10
  require "platformx/pdf"
14
11
  require "platformx/text"
12
+ require "platformx/aws"
15
13
 
16
14
  ########################### Require Gems ############################
17
15
  require "sinatra/base"
@@ -34,11 +32,12 @@ require "rack-ssl-enforcer"
34
32
  require "bugsnag"
35
33
  require "slugify"
36
34
  require "data_mapper"
35
+ require "dm-validations"
37
36
  require "securerandom"
38
- require "geokit"
39
37
  require "faker"
40
38
  require "uuidtools"
41
39
  require "net/ssh"
40
+ require "fog"
42
41
 
43
42
  module Platformx
44
43
 
@@ -46,18 +45,67 @@ module Platformx
46
45
  attr_accessor :configuration
47
46
  end
48
47
 
49
- def self.configuration
50
- @configuration ||= Configuration.new
48
+ def self.configure
49
+ self.configuration ||= Configuration.new
50
+ yield(configuration)
51
51
  end
52
52
 
53
- def self.reset
54
- @configuration = Configuration.new
55
- end
53
+ ########################################################
54
+ #
55
+ # Start Configuration Class
56
+ #
57
+ ########################################################
58
+ class Configuration
59
+
60
+ # For Bugsnag
61
+ attr_accessor :bugsnag_api_key
62
+
63
+ # X_mail
64
+ attr_accessor :mail_from
65
+ attr_accessor :mail_address
66
+ attr_accessor :mail_port
67
+ attr_accessor :mail_domain
68
+ attr_accessor :mail_user_name
69
+ attr_accessor :mail_password
70
+ attr_accessor :mail_authentication
71
+
72
+ # For AWS/Fog
73
+ attr_accessor :aws_bucket
74
+ attr_accessor :aws_access_key_id
75
+ attr_accessor :aws_secret_access_key
76
+ attr_accessor :aws_region
77
+
78
+ def initialize
79
+ # Bugsnag:
80
+ @bugsnag_api_key = ""
81
+
82
+ # X_mail
83
+ @mail_from = ""
84
+ @mail_address = "smtp.mailgun.org"
85
+ @mail_port = "587"
86
+ @mail_domain = "smtp.mailgun.org"
87
+ @mail_user_name = ""
88
+ @mail_password = ""
89
+ @mail_authentication = "plain"
90
+
91
+ # For AWS/Fog
92
+ @aws_bucket = ""
93
+ @aws_secret_access_key = ""
94
+ @aws_access_key_id = ""
95
+ @aws_region = ""
96
+ end
56
97
 
57
- def self.configure
58
- yield(configuration)
59
98
  end
60
99
 
100
+
101
+
102
+
103
+ ########################################################
104
+ #
105
+ # Start Sinatra Module
106
+ #
107
+ ########################################################
108
+
61
109
  module Sinatra
62
110
 
63
111
  def self.registered(app)
@@ -67,19 +115,19 @@ module Platformx
67
115
  app.helpers Platformx::FormHelpers
68
116
  app.helpers Platformx::LayoutHelpers
69
117
  app.helpers Platformx::NotifyHelpers
70
- app.helpers Platformx::GooglemapHelpers
71
- app.helpers Platformx::InstagramHelpers
72
118
  app.helpers Platformx::FakerHelpers
73
- app.helpers Platformx::TextHelpers
119
+ app.helpers Platformx::TextHelpers
120
+ app.helpers Platformx::PdfHelpers
121
+ app.helpers Platformx::S3Helpers
74
122
 
75
- #BugSnag
76
- if Platformx.configuration.bugsnag_api_key != ""
77
- app.Bugsnag.configure do |config|
78
- config.api_key = Platformx.configuration.bugsnag_api_key
79
- end
80
- app.use Bugsnag::Rack
81
- app.enable :raise_errors
82
- end
123
+ # #BugSnag
124
+ # if Platformx.configuration.bugsnag_api_key != ""
125
+ # app.Bugsnag.configure do |config|
126
+ # config.api_key = Platformx.configuration.bugsnag_api_key
127
+ # end
128
+ # app.use Bugsnag::Rack
129
+ # app.enable :raise_errors
130
+ # end
83
131
 
84
132
 
85
133
  # Configure Better Errors
@@ -93,9 +141,6 @@ module Platformx
93
141
  app.use Rack::Protection
94
142
  end
95
143
 
96
- #require_relative 'platformx/omniauth_routes.rb'
97
-
98
-
99
144
  end
100
145
 
101
146
  end # End Sinatra
@@ -0,0 +1,71 @@
1
+ module Platformx
2
+ module S3Helpers
3
+ ########################################################
4
+ #
5
+ # Set Up Connection
6
+ #
7
+ ########################################################
8
+ def x_s3_init()
9
+
10
+ connection = Fog::Storage.new({
11
+ :provider => 'AWS',
12
+ :region => Platformx.configuration.aws_region,
13
+ :aws_access_key_id => Platformx.configuration.aws_access_key_id,
14
+ :aws_secret_access_key => Platformx.configuration.aws_secret_access_key
15
+ })
16
+ return connection
17
+
18
+ end
19
+
20
+ ########################################################
21
+ #
22
+ # Upload to S3
23
+ #
24
+ ########################################################
25
+ def x_s3_upload(new_filename: "", file: "", bucket: "#{Platformx.configuration.aws_bucket}", path: "")
26
+
27
+
28
+ ################# Init S3 #################
29
+ connection = x_s3_init
30
+
31
+
32
+ ################# Set Bucket #################
33
+ bucket = connection.directories.create(key: "#{bucket}/#{path}", public: false)
34
+
35
+ # upload that resume
36
+ file = bucket.files.create(
37
+ :key => "#{new_filename}",
38
+ :body => open(file),
39
+ :public => false
40
+ )
41
+
42
+ end
43
+
44
+
45
+ ########################################################
46
+ #
47
+ # Download from S3
48
+ #
49
+ ########################################################
50
+ def x_s3_get_link(key: "", bucket:"", bucket_path:"", verbose: false)
51
+
52
+ connection = x_s3_init
53
+ expiry = Time.now.to_i + 604800
54
+ connection.directories.new(:key => "#{bucket}").files.new(:key => "#{bucket_path}/#{key}").url(expiry)
55
+
56
+ if verbose == true
57
+ # returns more information about file from s3
58
+ # directory = connection.directories.get("files.myclocktower.com")
59
+ # file = directory.files.get("support/#{support_id}/#{key}")
60
+ #return file.url(expiry)
61
+ end
62
+
63
+ end
64
+
65
+ ########################################################
66
+ #
67
+ # End
68
+ #
69
+ ########################################################
70
+ end
71
+ end
@@ -172,6 +172,94 @@ EOS
172
172
  end
173
173
 
174
174
 
175
+ ########################################################
176
+ #
177
+ # Money input helper
178
+ #
179
+ ########################################################
180
+ def x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
181
+
182
+ id = name unless id != ""
183
+ if required
184
+ if label != ""
185
+ required_output = '<sup class="text-danger">*</sup>'
186
+ else
187
+ required_output = ''
188
+ end
189
+ required_tag = 'required="required"'
190
+ else
191
+ required_output = ""
192
+ required_tag = ""
193
+ end
194
+
195
+ if label != ""
196
+ label = "<label>#{label}</label>"
197
+ end
198
+
199
+ if maxlength != ""
200
+ maxlength = "maxlength='#{maxlength}'"
201
+ end
202
+
203
+ if mask != ""
204
+ mask = "data-masked-input='#{mask}'"
205
+ end
206
+
207
+ tb = <<EOS
208
+ <div class="form-group">
209
+ <div class="input-group">
210
+ <span class="input-group-addon">$</span>
211
+ #{label}#{required_output}
212
+ <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
213
+ </div>
214
+ </div>
215
+ EOS
216
+ return tb
217
+ end
218
+
219
+ ########################################################
220
+ #
221
+ # Percentage input helper
222
+ #
223
+ ########################################################
224
+ def x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")
225
+
226
+ id = name unless id != ""
227
+ if required
228
+ if label != ""
229
+ required_output = '<sup class="text-danger">*</sup>'
230
+ else
231
+ required_output = ''
232
+ end
233
+ required_tag = 'required="required"'
234
+ else
235
+ required_output = ""
236
+ required_tag = ""
237
+ end
238
+
239
+ if label != ""
240
+ label = "<label>#{label}</label>"
241
+ end
242
+
243
+ if maxlength != ""
244
+ maxlength = "maxlength='#{maxlength}'"
245
+ end
246
+
247
+ if mask != ""
248
+ mask = "data-masked-input='#{mask}'"
249
+ end
250
+
251
+ tb = <<EOS
252
+ <div class="form-group">
253
+ <div class="input-group">
254
+ <span class="input-group-addon">%</span>
255
+ #{label}#{required_output}
256
+ <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
257
+ </div>
258
+ </div>
259
+ EOS
260
+ return tb
261
+ end
262
+
175
263
  ########################################################
176
264
  #
177
265
  # Number input helper
@@ -0,0 +1,42 @@
1
+ module Platformx
2
+ module PdfHelpers
3
+ ########################################################
4
+ #
5
+ # PDF's
6
+ #
7
+ ########################################################
8
+
9
+
10
+
11
+ ################# Fill PDF #################
12
+ def x_fill_pdf(source_pdf: "", target_file_path: "", new_pdf_name: "", pdf_variables: {}, flatten: true)
13
+ # include pdftk
14
+ pdftk = PdfForms.new(settings.pdftk_path)
15
+
16
+ #find out the field names that are present in form.pdf
17
+ #pdftk.get_field_names 'pdfs/cover_opt.pdf'
18
+ #pdf_name = Time.new.to_i
19
+ pdf_name = @proposal.id
20
+
21
+ #Fill Out the forms
22
+ pdftk.fill_form source_pdf, "#{target_file_path}/#{pdf_name}",
23
+ {
24
+ Client: @proposal.client,
25
+ proposalDate: "#{format_date(Date.today)}",
26
+ expires: format_date(1.month.from_now)
27
+ },
28
+ :flatten => flatten
29
+ end
30
+
31
+
32
+
33
+
34
+
35
+
36
+ ########################################################
37
+ #
38
+ # End Class
39
+ #
40
+ ########################################################
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Platformx
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -41,8 +41,9 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "sinatra-flash"
42
42
  spec.add_dependency "data_mapper"
43
43
  spec.add_dependency "dm-mysql-adapter"
44
- spec.add_dependency "geokit"
44
+ spec.add_dependency "dm-validations"
45
45
  spec.add_dependency "faker"
46
46
  spec.add_dependency "uuidtools"
47
47
  spec.add_dependency "net-ssh"
48
+ spec.add_dependency "fog"
48
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platformx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - timmushen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-22 00:00:00.000000000 Z
11
+ date: 2016-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -305,7 +305,7 @@ dependencies:
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
307
  - !ruby/object:Gem::Dependency
308
- name: geokit
308
+ name: dm-validations
309
309
  requirement: !ruby/object:Gem::Requirement
310
310
  requirements:
311
311
  - - ">="
@@ -360,6 +360,20 @@ dependencies:
360
360
  - - ">="
361
361
  - !ruby/object:Gem::Version
362
362
  version: '0'
363
+ - !ruby/object:Gem::Dependency
364
+ name: fog
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - ">="
368
+ - !ruby/object:Gem::Version
369
+ version: '0'
370
+ type: :runtime
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - ">="
375
+ - !ruby/object:Gem::Version
376
+ version: '0'
363
377
  description: PlatformX Gem for PlatformX
364
378
  email:
365
379
  - timmushen@clocktowermedia.com
@@ -375,13 +389,10 @@ files:
375
389
  - Rakefile
376
390
  - lib/platformx.rb
377
391
  - lib/platformx/auth.rb
378
- - lib/platformx/configuration.rb
392
+ - lib/platformx/aws.rb
379
393
  - lib/platformx/date.rb
380
- - lib/platformx/facebook.rb
381
394
  - lib/platformx/faker.rb
382
395
  - lib/platformx/form.rb
383
- - lib/platformx/google_map.rb
384
- - lib/platformx/instagram.rb
385
396
  - lib/platformx/layout.rb
386
397
  - lib/platformx/mail.rb
387
398
  - lib/platformx/notify.rb
@@ -389,10 +400,7 @@ files:
389
400
  - lib/platformx/omniauth_routes.rb
390
401
  - lib/platformx/pdf.rb
391
402
  - lib/platformx/stripe.rb
392
- - lib/platformx/template.rb
393
403
  - lib/platformx/text.rb
394
- - lib/platformx/timeline.rb
395
- - lib/platformx/twitter.rb
396
404
  - lib/platformx/version.rb
397
405
  - platformx.gemspec
398
406
  - spec/layout_spec.rb
@@ -1,35 +0,0 @@
1
- module Platformx
2
- class Configuration
3
-
4
- attr_accessor :bugsnag_api_key
5
- attr_accessor :mail_from
6
- attr_accessor :mail_address
7
- attr_accessor :mail_port
8
- attr_accessor :mail_domain
9
- attr_accessor :mail_user_name
10
- attr_accessor :mail_password
11
- attr_accessor :mail_authentication
12
-
13
-
14
- def initialize
15
- #Example:
16
- @bugsnag_api_key = ""
17
- @mail_from = ""
18
- @mail_address = "smtp.mailgun.org"
19
- @mail_port = "587"
20
- @mail_domain = "smtp.mailgun.org"
21
- @mail_user_name = ""
22
- @mail_password = ""
23
- @mail_authentication = "plain"
24
- end
25
-
26
- end
27
-
28
- end
29
-
30
-
31
- # Platformx.configure do |config|
32
- # config.access_key = ''
33
- # config.secret_key = ''
34
- # config.personal_key = ''
35
- # end
@@ -1,16 +0,0 @@
1
- module Platformx
2
- module FacebookHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
-
9
-
10
- ########################################################
11
- #
12
- # End
13
- #
14
- ########################################################
15
- end
16
- end
@@ -1,42 +0,0 @@
1
- module Platformx
2
- module GooglemapHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
-
9
- # Start Google Map
10
- def x_google_map(css: "", id: "map", address: "", address_2:"", city:"", state:"", zip:"", zoom:"12", height: "400px", width: "520px")
11
-
12
-
13
- geo=Geokit::Geocoders::GoogleGeocoder.geocode "#{address} #{address_2}, #{city} #{state} #{zip}"
14
- #Get Lat & long
15
-
16
- cb = <<EOS
17
- <script src="https://maps.googleapis.com/maps/api/js"></script>
18
- <script>
19
- function initialize() {
20
- var mapCanvas = document.getElementById('#{id}');
21
- var mapOptions = {
22
- center: new google.maps.LatLng(#{geo.ll}),
23
- zoom: #{zoom},
24
- mapTypeId: google.maps.MapTypeId.ROADMAP
25
- }
26
- var map = new google.maps.Map(mapCanvas, mapOptions)
27
- }
28
- google.maps.event.addDomListener(window, 'load', initialize);
29
- </script>
30
-
31
- <div id="#{id}" class="#{css}"></div>
32
-
33
- EOS
34
-
35
- end
36
- ########################################################
37
- #
38
- # End
39
- #
40
- ########################################################
41
- end
42
- end
@@ -1,115 +0,0 @@
1
- module Platformx
2
- module InstagramHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
-
9
- # def self.init
10
- # Instagram.configure do |config|
11
- # config.client_id = Platformx.configuration.instagram_key
12
- # config.client_secret = Platformx.configuration.instagram_secret
13
- # # For secured endpoints only
14
- # #config.client_ips = '<Comma separated list of IPs>'
15
- # end
16
- # @client = Instagram.client(access_token: access_token)
17
-
18
- # return @client
19
- # end
20
-
21
-
22
-
23
- ########################### Get Recent Feed ############################
24
-
25
- def x_instagram_recent(access_token: "")
26
- @client = Instagram.client(access_token: access_token)
27
- user = @client.user
28
-
29
- @feed = []
30
-
31
- for media_item in @client.user_recent_media
32
-
33
- item = {
34
- :thumb_url => media_item.images.thumbnail.url,
35
- :id => media_item.id,
36
- :likes => media_item.likes[:count]
37
- }
38
-
39
- @feed.push(item)
40
-
41
- end
42
-
43
- return @feed
44
-
45
- end
46
-
47
- ########################### Search by Location ID ############################
48
-
49
- # def x_instagram_by_location(access_token: "", location_id: "")
50
- # html = "<h1>Media</h1>"
51
-
52
- # for media_item in @client.location_recent_media(location_id)
53
- # html << "<img src='#{media_item.images.thumbnail.url}'>"
54
- # end
55
- # return html
56
-
57
- # end
58
-
59
- # ########################### Search By Lat/Long ############################
60
- # def x_instagram_by_lat_long(access_token: "", latitude: "", longitude: "")
61
- # html = "<h1>Get a list of media close to a given latitude and longitude</h1>"
62
-
63
- # for media_item in @client.media_search(latitude,longitude)
64
- # html << "<img src='#{media_item.images.thumbnail.url}'>"
65
- # end
66
-
67
- # return html
68
- # end
69
-
70
- # ########################### Nearby Locations ############################
71
- # def x_instagram_nearby_locations(access_token: "", latitude: "", longitude: "", radius: "5000")
72
- # html = "<h1>Search for a location by lat/lng with a radius of #{radius}m</h1>"
73
- # for location in @client.location_search(latitude,longitude,radius)
74
- # html << "<li> #{location.name} <a href='https://www.google.com/maps/preview/@#{location.latitude},#{location.longitude},19z'>Map</a></li>"
75
- # end
76
- # return html
77
-
78
- # end
79
-
80
- # ########################### Search by tag ############################
81
- # def x_instagram_tag(access_token: "", tag: "")
82
- # html = "<h1>Search for #{tag}</h1>"
83
- # tags = @client.tag_search(tag)
84
- # html << "<h2>Tag Name = #{tags[0].name}. Media Count = #{tags[0].media_count}. </h2><br/><br/>"
85
- # for media_item in @client.tag_recent_media(tags[0].name)
86
- # html << "<img src='#{media_item.images.thumbnail.url}'>"
87
- # end
88
- # return html
89
-
90
- # end
91
-
92
- # ########################### User Search ############################
93
- # def x_instagram_user(access_token: "", user: "")
94
- # html = "<h1>Search for #{user}</h1>"
95
- # for user in @client.user_search(user)
96
- # html << "<li> <img src='#{user.profile_picture}'> #{user.username} #{user.full_name}</li>"
97
- # end
98
- # return html
99
- # end
100
-
101
- # ########################### Limits ############################
102
- # def x_instagram_limits(access_token: "")
103
- # html = "<h1/>View API Rate Limit and calls remaining</h1>"
104
- # response = @client.utils_raw_response
105
- # html << "Rate Limit = #{response.headers[:x_ratelimit_limit]}. <br/>Calls Remaining = #{response.headers[:x_ratelimit_remaining]}"
106
-
107
- # return html
108
- # end
109
- ########################################################
110
- #
111
- # End
112
- #
113
- ########################################################
114
- end
115
- end
@@ -1,16 +0,0 @@
1
- module Platformx
2
- module InstagramHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
-
9
-
10
- ########################################################
11
- #
12
- # End
13
- #
14
- ########################################################
15
- end
16
- end
@@ -1,55 +0,0 @@
1
- module Platformx
2
- module TimelineHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
- ########################### Init ############################
9
- def x_timeline(left_aligned: false, items: array)
10
-
11
- timeline_items =""
12
- total_items = items.count
13
-
14
- items.each_with_index do |item, index|
15
-
16
- inverted = ""
17
- if !left_aligned == false || index.even?
18
- inverted = "inverted"
19
- end
20
-
21
- item =<<EOS
22
- <li class="#{inverted}">
23
- <div class="timeline-badge"><i class="fa #{item[:icon]}"></i></div>
24
- <div class="timeline-panel">
25
- <div class="timeline-heading">
26
- <h4 class="timeline-title">#{item[:title]}</h4>
27
- <p><small class="text-muted">#{item[:time]}</small></p>
28
- </div>
29
- <div class="timeline-body">
30
- #{item[:body]}
31
- </div>
32
- </div>
33
- </li>
34
- EOS
35
- timeline_items << item
36
- end
37
-
38
- timeline =<<EOS
39
- <div class="timeline_wrapper">
40
- <ul class="timeline">
41
- #{timeline_items}
42
- </ul>
43
- </div>
44
- EOS
45
-
46
- return timeline
47
- end
48
-
49
- ########################################################
50
- #
51
- # End
52
- #
53
- ########################################################
54
- end
55
- end
@@ -1,47 +0,0 @@
1
- module Platformx
2
- module Twitter
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
-
9
- ########################### Init ############################
10
- def x_twitter_init(access_token="", access_token_secret="")
11
- client = Twitter::REST::Client.new do |config|
12
- config.access_token = access_token
13
- config.access_token_secret = access_token_secret
14
- config.consumer_key = Platformx.configuration.twitter_consumer_key
15
- config.consumer_secret = Platformx.configuration.twitter_consumer_secret
16
- end
17
- return client
18
- end
19
-
20
- ########################### Post ############################
21
- def x_twitter_post(access_token: "", access_token_secret:"", tweet:"", place_id: "", lat: "", long: "", display_coordinates: "")
22
- client = x_twitter_init(access_token, access_token_secret)
23
- client.update(tweet, place_id: place_id, lat: lat, long: long, display_coordinates: display_coordinates)
24
- return client
25
- end
26
-
27
- ########################### Post with Media ############################
28
- def x_twitter_post_media(access_token: "", access_token_secret:"", tweet:"", place_id: "", lat: "", long: "", display_coordinates: "", media: "")
29
- client = x_twitter_init(access_token, access_token_secret)
30
- client.update_with_media(tweet, media, place_id: "", lat: "", long: "", display_coordinates: "")
31
- return client
32
- end
33
-
34
- ########################### Get Tweet ############################
35
- def x_twitter_tweet(access_token: "", access_token_secret:"", tweet: "")
36
- client = x_twitter_init(access_token, access_token_secret)
37
- client.status(tweet)
38
- return client
39
- end
40
-
41
- ########################################################
42
- #
43
- # End
44
- #
45
- ########################################################
46
- end
47
- end