forked from jonallured/appboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from shopsmart/list_canvas_endpoint
List canvas endpoint
- Loading branch information
Showing
10 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Appboy | ||
module Endpoints | ||
module ListCanvas | ||
def list_canvas(**payload) | ||
list_canvas_service.new(app_group_id, payload).perform | ||
end | ||
|
||
private | ||
|
||
def list_canvas_service | ||
Appboy::REST::ListCanvas | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Appboy | ||
module REST | ||
class ListCanvas < Base | ||
attr_reader :app_group_id, :sort_direction, :include_archived | ||
|
||
def initialize(app_group_id, options = {}) | ||
@app_group_id = app_group_id | ||
@sort_direction = options[:sort_direction] | ||
@include_archived = options[:include_archived] | ||
end | ||
|
||
def perform | ||
http.get '/canvas/list', { | ||
app_group_id: app_group_id, | ||
sort_direction: sort_direction, | ||
include_archived: include_archived | ||
}.compact | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Appboy | ||
VERSION = '0.1.6' | ||
VERSION = '0.1.7' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'spec_helper' | ||
|
||
describe Appboy::REST::ListCanvas do | ||
let(:http) { double(:http) } | ||
|
||
let(:payload) {{ | ||
sort_direction: "desc", | ||
include_archived: false | ||
}} | ||
|
||
let(:app_group_id) { :app_group_id } | ||
|
||
subject { described_class.new(:app_group_id, sort_direction: "desc", include_archived: false) } | ||
|
||
before { subject.http = http } | ||
|
||
it 'makes an http call to the list canvas endpoint' do | ||
expect(http).to receive(:get).with '/canvas/list', | ||
payload.merge({ app_group_id: :app_group_id }) | ||
|
||
subject.perform | ||
end | ||
end |
67 changes: 67 additions & 0 deletions
67
spec/fixtures/responses/list_canvas/with_success/responds_with_a_list_of_segments.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
spec/fixtures/responses/list_canvas/with_success/responds_with_success.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe 'list canvas' do | ||
subject(:list_canvas) { api.list_canvas } | ||
|
||
context 'with success', :vcr do | ||
it 'responds with success' do | ||
expect(list_canvas).to be_success | ||
end | ||
|
||
it 'responds with a list of segments' do | ||
expect(canvases.count).to be 4 | ||
|
||
expect(canvases.first['name']).to eq 'ONBOARDING_NEW SUBSCRIBERS' | ||
end | ||
|
||
def canvases | ||
JSON.parse(list_canvas.body)['canvases'] | ||
end | ||
end | ||
end |