BAT_Notifications 0.0.0 → 0.0.4

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.
@@ -0,0 +1,32 @@
1
+ # this module contains all the booking functions that are shared between
2
+ # the booking decorators
3
+
4
+ require 'geocoder'
5
+
6
+ # Geocoder.configure(
7
+ # # geocoding options
8
+ # :timeout => 7, # geocoding service timeout (secs)
9
+ # :lookup => :google, # name of geocoding service (symbol)
10
+ # :language => :en, # ISO-639 language code
11
+ # :use_https => true, # use HTTPS for lookup requests? (if supported)
12
+ # :http_proxy => '', # HTTP proxy server (user:pass@host:port)
13
+ # :https_proxy => '', # HTTPS proxy server (user:pass@host:port)
14
+ # :api_key => "", # API key for geocoding service
15
+ # :cache => nil, # cache object (must respond to #[], #[]=, and #keys)
16
+ # :cache_prefix => "geocoder:", # prefix (string) to use for all cache keys
17
+ # )
18
+
19
+ module BookingFunctions
20
+ def self.get_location(content)
21
+ @location = Geocoder.search("#{content["location"]["latitude"]}, #{content["location"]["longitude"]}")[0].data
22
+ end
23
+
24
+ def self.get_booking_message(content)
25
+ self.get_location(content)
26
+ @booking_message = "<p>Location: #{@location["address"]["address29"]}</p> \r\n
27
+ <p>Time Booked: #{Time.at(content["date"].to_time.to_i).httpdate}</p> \r\n
28
+ <p>Hours Booked: #{content["hours_booked"]}</p> \r\n
29
+ "
30
+ end
31
+
32
+ end
@@ -0,0 +1,10 @@
1
+ # this module contains all the review functions that are shared between
2
+ # the review decorators
3
+
4
+ module ReviewFunctions
5
+ def self.get_review_message(content)
6
+ @review_message = "<p>Review Content: #{content['review_content']}</p>
7
+ <p>Review Stars: #{content['review_stars']}"
8
+ end
9
+ end
10
+
@@ -0,0 +1,16 @@
1
+ require_relative 'Notification'
2
+ require_relative 'NotificationDb'
3
+ require_relative "Content.rb"
4
+
5
+ require "async"
6
+
7
+ notify = Notification.new(NotificationDb.get_sender, NotificationDb.get_receiver, Content.booking_content)
8
+ var_dump(notify)
9
+
10
+ notify = BookingNotification.new(notify)
11
+ var_dump(notify)
12
+
13
+ notify = UserBookingNotification.new(notify)
14
+ #puts notify.get_content
15
+ #notify.send_notification
16
+ var_dump(notify)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BAT_Notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Femi Abdul
@@ -22,10 +22,13 @@ files:
22
22
  - lib/BookingNotificationDecorator.rb
23
23
  - lib/Content.rb
24
24
  - lib/InboxNotificationDecorator.rb
25
- - lib/Notification.rb
26
25
  - lib/NotificationDb.rb
27
26
  - lib/ReviewNotificationDecorator.rb
28
27
  - lib/SendNotification.rb
28
+ - lib/bat_notifications.rb
29
+ - lib/functions/BookingFunctions.rb
30
+ - lib/functions/ReviewFunctions.rb
31
+ - lib/interface.rb
29
32
  homepage: http://rubygems.org/gems/bat_notifications
30
33
  licenses: []
31
34
  metadata: {}
@@ -44,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
47
  - !ruby/object:Gem::Version
45
48
  version: '0'
46
49
  requirements: []
47
- rubygems_version: 3.0.3
50
+ rubygems_version: 3.0.6
48
51
  signing_key:
49
52
  specification_version: 4
50
53
  summary: Send notification to users
@@ -1,153 +0,0 @@
1
- require 'delegate'
2
- require 'pony'
3
-
4
- # class Notification
5
-
6
-
7
- # def message
8
- # return "This is get message from #{@action}"
9
- # end
10
-
11
- # def read_message
12
- # return "this is read message"
13
- # end
14
-
15
- # def get_action
16
- # return @action
17
- # end
18
-
19
-
20
-
21
- # end
22
-
23
- class NotificationDecorator < SimpleDelegator
24
- #initialize our constructor
25
- def initialize(action, sender, receiver, content)
26
- #super(notificationBase)
27
- @action = action
28
- @sender = sender
29
- @receiver = receiver
30
- @content = content
31
- end
32
-
33
- def booking_method
34
- return "this is booking method"
35
- end
36
-
37
- #get content
38
- def get_content
39
- return @content
40
- end
41
-
42
- #get sender information
43
- def get_sender
44
- return @sender
45
- end
46
-
47
- #get receiver information
48
- def get_receiver
49
- return @receiver
50
- end
51
-
52
- #get action i.e review, booking etc
53
- def get_action
54
- return @action
55
- end
56
-
57
- #send email using Pony
58
- def send_email
59
- begin
60
- Pony.mail(
61
- :to => @receiver_email,
62
- :from => @sender_email,
63
- :subject => "You have a new #{@action}",
64
- :html_body => "<h1>You have received a #{@action} from #{@sender["firstname"]}. Details Below</h1><p>#{@mail_content} " ,
65
- :body => "You have received a #{@action} from #{@sender["firstname"]}. #{@mail_content}",
66
- :via => :smtp,
67
- :via_options => {
68
- :address => 'smtp.gmail.com',
69
- :port => '587',
70
- :enable_starttls_auto => true,
71
- :user_name => 'bookatutorapp@gmail.com',
72
- :password => 'b00katut0r@123!',
73
- :authentication => :plain,
74
- :domain => "localhost.localdomain"
75
- }
76
- )
77
-
78
- #return message-sent == true
79
-
80
- rescue Exception => e
81
- puts e.message
82
- puts e.backtrace.inspect
83
- end
84
- end
85
-
86
- #send notification using async
87
- def send_notification
88
- @sender_email = self.get_sender["email"]
89
- @receiver_email = self.get_receiver["email"]
90
- @mail_content = message
91
-
92
- mail_status = Async do
93
- self.send_email
94
- end
95
-
96
- return mail_status.wait.content_type.length
97
-
98
-
99
-
100
-
101
- end
102
-
103
-
104
- end
105
-
106
- class BasicNotification < NotificationDecorator
107
- def message
108
- return "You have a new #{@action} from #{@sender}. Check out the details"
109
- end
110
-
111
-
112
- end
113
-
114
- class BookingNotification < NotificationDecorator
115
- def message
116
- return "You have a new #{@action} from #{@sender}. Check out the details"
117
- end
118
-
119
- def get_content
120
- return @content
121
- end
122
- end
123
-
124
- class ReviewNotification < NotificationDecorator
125
- def message
126
- return "You have a new #{@action} from #{@sender}. Check out the details"
127
- end
128
-
129
- def get_content
130
- return @content
131
- end
132
- end
133
-
134
- class InboxNotification < NotificationDecorator
135
- def message
136
- return "You have a new #{@action} from #{@sender}. Check out the details"
137
- end
138
-
139
- def get_content
140
- return @content
141
- end
142
- end
143
-
144
- class AppMessageNotification < NotificationDecorator
145
- def message
146
- return "You have a new #{@action} from #{@sender}. Check out the details"
147
- end
148
-
149
- def get_content
150
- return @content
151
- end
152
- end
153
-