digitsend 0.0.9 → 0.0.10
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/README.md +82 -17
- data/lib/digitsend/repository.rb +1 -1
- data/lib/digitsend/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,29 +1,94 @@
|
|
1
|
-
#
|
1
|
+
# DigitSend
|
2
2
|
|
3
|
-
|
3
|
+
DigitSend is a secure email and file sharing service with a streamlined
|
4
|
+
two-factor registration process. This gem allows you to send email and upload
|
5
|
+
files to share programmatically.
|
4
6
|
|
5
|
-
##
|
7
|
+
## Usage
|
6
8
|
|
7
|
-
|
9
|
+
### 1. API Key
|
8
10
|
|
9
|
-
|
11
|
+
You must set the API key before performing any operations. API keys are
|
12
|
+
granted on a per-user basis using the administration portal. All operations
|
13
|
+
are done on behalf of the user to which the API key belongs.
|
10
14
|
|
11
|
-
|
15
|
+
```ruby
|
16
|
+
DigitSend::Config.api_token = 'bdf6a88dcb7e3ff3df18afda99591360'
|
17
|
+
```
|
18
|
+
|
19
|
+
### 2. Sending Messages
|
12
20
|
|
13
|
-
|
21
|
+
The general approach:
|
14
22
|
|
15
|
-
|
23
|
+
```ruby
|
24
|
+
DigitSend::Message.send do |m|
|
25
|
+
m.to "bob@example.com", "3125551234"
|
26
|
+
m.to "tom@example.com", "7731112222"
|
27
|
+
m.cc "fred@example.com"
|
28
|
+
m.subject "Hello Bob, Tom, and Fred"
|
29
|
+
m.body "Here's a message, hope you enjoy!"
|
30
|
+
m.attach "report.xls"
|
31
|
+
m.attach "notes.txt", "here's the contents of notes.txt"
|
32
|
+
end
|
33
|
+
```
|
16
34
|
|
17
|
-
|
35
|
+
A few things to note:
|
18
36
|
|
19
|
-
|
37
|
+
* Call to or cc multiple times to add multiple recipients.
|
38
|
+
* The second (optional) argument to the to and cc methods is that user's phone
|
39
|
+
number. The phone number is required if this is the first message being sent
|
40
|
+
to the user.
|
41
|
+
|
42
|
+
### 3. DigitSend::MissingPhoneNumbers
|
43
|
+
|
44
|
+
This exception is thrown whenever an attempt is made to send a message to a new
|
45
|
+
user without providing a phone number:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
begin
|
49
|
+
DigitSend::Message.send do |m|
|
50
|
+
m.to "bob@example.com"
|
51
|
+
m.subject "Testing"
|
52
|
+
m.body "Here's a test mesage"
|
53
|
+
end
|
54
|
+
rescue DigitSend::MissingPhoneNumbers => ex
|
55
|
+
puts "need phone numbers for: #{ex.email_addresses}"
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
### 4. Message File Attachments
|
60
|
+
|
61
|
+
The attach method can be called a number of ways:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
DigitSend::Message.send do |m|
|
65
|
+
m.to "bob@example.com"
|
66
|
+
m.subject "Here's some attachments"
|
67
|
+
|
68
|
+
# Attach the report.xls file on disk.
|
69
|
+
m.attach "/path/to/report.xls"
|
70
|
+
|
71
|
+
# Attach a file with its contents specified as a string.
|
72
|
+
m.attach "reports.txt", "contents of the file"
|
73
|
+
|
74
|
+
# Attach a file with its contents specified as any object
|
75
|
+
# that can be passed to UploadIO.new.
|
76
|
+
m.attach "picture.jpg", File.open("picture.jpg")
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
### 5. Uploading Files to Repositories
|
20
81
|
|
21
|
-
|
82
|
+
Repositories are referenced by name and must be created in using the admin
|
83
|
+
portal.
|
22
84
|
|
23
|
-
|
85
|
+
```ruby
|
86
|
+
DigitSend::Repository.upload "Reports", "/Internal/#{Date.today}", "activity.csv"
|
87
|
+
```
|
24
88
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
89
|
+
* The first parameter is the name of the repository.
|
90
|
+
* The second parameter identifies the folder to which the file should belong. Folders are created on the fly, mkdir_p style.
|
91
|
+
* The third parameter is the name of the file.
|
92
|
+
* The optional fourth parameter can can be the string contents of the file or
|
93
|
+
an object; it has the same behavior as with message attachments described
|
94
|
+
above.
|
data/lib/digitsend/repository.rb
CHANGED
data/lib/digitsend/version.rb
CHANGED