whispir 0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/whispir.rb +40 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b438f8ff8fafe00fa04471d589711e235b6158e5
4
+ data.tar.gz: ea5fb8633cdd677aa0bfd0e95ce7cc251582ea56
5
+ SHA512:
6
+ metadata.gz: b43b1ecf62beb7fc55e05b302acf12ce88b0fcf0f9ff66395a8b132af26c877b814d2f74249ef39b0c5eadeaf703df74007c9cb050b3e51501eef7f0b8507c11
7
+ data.tar.gz: e6d6f5c05b580134b1bb14bd641831d87b75adc665a94342ba32434d638714b305b6d780905551110333cf036f8f75269505fb9605a42352c08ac4bfefc30519
@@ -0,0 +1,40 @@
1
+ require 'net/http'
2
+ require "uri"
3
+ require 'openssl'
4
+ require 'json'
5
+
6
+ class Whispir
7
+
8
+ base_uri = 'https://api.whispir.com/messages'
9
+
10
+ def initialize(api_key, authorization)
11
+ @api_key = api_key
12
+ @authorization = authorization
13
+ end
14
+
15
+ # whispir = Whispir.new(API_KEY, AUTHORIZATION)
16
+ # whispir.send_email({email: {email_id: "test@mail.com", recipient_name: "Test Name"
17
+ # email_subject: "Test Subject", email_body: "test body"},{}})
18
+
19
+ def send_email(email_hash)
20
+ request_uri = "https://api.whispir.com/messages?apikey=#{@api_key}"
21
+ url = URI.parse(request_uri)
22
+ http = Net::HTTP.new(url.host, url.port)
23
+ http.use_ssl = true
24
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
25
+ request = Net::HTTP::Post.new(url.to_s)
26
+ request["authorization"] = @authorization
27
+ request["accept"] = 'application/vnd.whispir.message-v1+json'
28
+ request["content-type"] = 'application/vnd.whispir.message-v1+json'
29
+
30
+ email_subject = email_hash[:email_subject]
31
+ email_body = email_hash[:email_body]
32
+ recipient_name = email_hash[:recipient_name]
33
+ email_id = email_hash[:email_id]
34
+ tmp_email_body = {"to" => email_id, "subject" => email_subject,
35
+ "email" => { "type" => "text/html", "body" => email_body}}
36
+ request.body = tmp_email_body.to_json
37
+ response = http.request(request)
38
+
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whispir
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Avijit Majhi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Sending email gem using whispir api
14
+ email: avijit1257.it@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/whispir.rb
20
+ homepage: http://rubygems.org/gems/whispir
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.1.9
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Send Email
44
+ test_files: []