Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/esendex/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,5 @@ def send_messages(messages)
response = api_connection.post("/v1.0/messagedispatcher", batch_submission.to_s)
DispatcherResult.from_xml response.body
end

def sent_messages(args={})
SentMessageClient
.new(api_connection)
.get_messages(args.merge(account_reference: reference))
end
end
end
16 changes: 4 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This is in early stages of development but supports the primary requirements aro

### Setting up

Requires Rails 5

From the command line

gem install esendex
Expand Down Expand Up @@ -51,16 +53,6 @@ Multiple messages are sent by passing an array of `Messages` to the `send_messag
result = account.send_messages([Message.new("07777111222", "Hello"), Message.new("07777111333", "Hi")])
```

Sent messages can be retrieved by calling the `sent_messages` method. The return value is a *SentMessagesResult*

```ruby
result = account.sent_messages
puts result
result.messages.each do |message|
puts message
end
```

### Testing Configuration

The Esendex Gem ships with a couple of rake tasks that allow you to simply validate that all is well.
Expand Down Expand Up @@ -96,9 +88,9 @@ Classes are provided in the gem for deserialising the notifications: `MessageDel
message = InboundMessage.from_xml request.body
```

### Rails 3 / Rails 4
### Rails

In order to simplify receipt of push notifications for Rails 3 users, the gem ships with mountable Rails controllers to handle the receipt of these notifications.
In order to simplify receipt of push notifications for Rails users, the gem ships with mountable Rails controllers to handle the receipt of these notifications.

To mount the end points, add this to `routes.rb`

Expand Down
79 changes: 0 additions & 79 deletions spec/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,83 +129,4 @@
subject.messages.should include(id: "#{message_two_id}", uri: "#{uri_prefix}#{message_two_id}")
end
end

describe "#sent_messages" do
let(:sent_message_client) { stub("sent_message_client") }
let(:sent_messages_result) { Class.new }

before(:each) do
stub_const("Esendex::SentMessageClient", sent_message_client)
sent_message_client
.should_receive(:new)
.with(api_connection)
.and_return(sent_message_client)
end

context "with no args" do
before(:each) do
sent_message_client
.should_receive(:get_messages)
.with({account_reference: account_reference})
.and_return(sent_messages_result)
end

subject { account.sent_messages() }

it "should return expected result" do
subject.should eq(sent_messages_result)
end
end

context "with start and finish dates" do
it "should pass dates without adjustment" do
start_date = DateTime.now - 30
finish_date = DateTime.now - 15
sent_message_client
.should_receive(:get_messages)
.with({account_reference: account_reference, start: start_date, finish: finish_date})
.and_return(sent_messages_result)

account.sent_messages({start: start_date, finish: finish_date}).should_not be_nil
end
end

context "with start date" do
it "should specify start date and default finish date" do
start_date = DateTime.now - 1
sent_message_client
.should_receive(:get_messages)
.with({account_reference: account_reference, start: start_date})
.and_return(sent_messages_result)

account.sent_messages({start: start_date}).should_not be_nil
end
end

context "with finish date" do
it "should specify default start date and finish date" do
finish_date = DateTime.now - 1
start_date = finish_date - 90
sent_message_client
.should_receive(:get_messages)
.with({account_reference: account_reference, finish: finish_date})
.and_return(sent_messages_result)

account.sent_messages({finish: finish_date}).should_not be_nil
end
end

context "with start index and count" do
it "should pass expected arguments" do
start_index = 3
count = 35
sent_message_client
.should_receive(:get_messages)
.with({account_reference: account_reference, start_index: start_index, count: count})
.and_return(sent_messages_result)

account.sent_messages({start_index: start_index, count: count}).should_not be_nil
end
end
end
end