-
Notifications
You must be signed in to change notification settings - Fork 67
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 #14 from PagerDuty/browse-programs
feat(programs): add API calls for program reading
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.swp |
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,16 @@ | ||
module Mrkt | ||
module CrudPrograms | ||
def browse_programs(offset: nil, max_return: nil, status: nil) | ||
params = {} | ||
params[:offset] = offset if offset | ||
params[:maxReturn] = max_return if max_return | ||
params[:status] = status if status | ||
|
||
get('/rest/asset/v1/programs.json', params) | ||
end | ||
|
||
def get_program_by_id(id) | ||
get("/rest/asset/v1/program/#{id}.json") | ||
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
describe Mrkt::CrudPrograms do | ||
include_context 'initialized client' | ||
|
||
describe '#browse_programs' do | ||
let(:response_stub) do | ||
{ | ||
success: true, | ||
warnings: [], | ||
errors: [], | ||
requestId: '7a39#1511bf8a41c', | ||
result: [ | ||
{ | ||
id: 1035, | ||
name: 'clone it', | ||
description: '', | ||
createdAt: '2015-11-18T15:25:35Z+0000', | ||
updatedAt: '2015-11-18T15:25:46Z+0000', | ||
url: 'https://app-devlocal1.marketo.com/#NP1035A1', | ||
type: 'Engagement', | ||
channel: 'Nurture', | ||
folder: { | ||
type: 'Folder', | ||
value: 28, | ||
folderName: 'Nurturing' | ||
}, | ||
status: 'on', | ||
workspace: 'Default' | ||
} | ||
] | ||
} | ||
end | ||
|
||
subject { client.browse_programs } | ||
|
||
before do | ||
stub_request(:get, "https://#{host}/rest/asset/v1/programs.json") | ||
.to_return(json_stub(response_stub)) | ||
end | ||
|
||
it { is_expected.to eq(response_stub) } | ||
end | ||
|
||
describe '#get_program_by_id' do | ||
let(:response_stub) do | ||
{ | ||
success: true, | ||
warnings: [], | ||
errors: [], | ||
requestId: '948f#14db037ec71', | ||
result: [ | ||
{ | ||
id: 1107, | ||
name: 'AAA2QueryProgramName', | ||
description: 'AssetAPI: getProgram tests', | ||
createdAt: '2015-05-21T22:45:13Z+0000', | ||
updatedAt: '2015-05-21T22:45:13Z+0000', | ||
url: 'https://app-devlocal1.marketo.com/#PG1107A1', | ||
type: 'Default', | ||
channel: 'Online Advertising', | ||
folder: { | ||
type: 'Folder', | ||
value: 1910, | ||
folderName: 'ProgramQueryTestFolder' | ||
}, | ||
status: '', | ||
workspace: 'Default', | ||
tags: [ | ||
{ | ||
tagType: 'AAA1 Required Tag Type', | ||
tagValue: 'AAA1 RT1' | ||
} | ||
], | ||
costs: nil | ||
} | ||
] | ||
} | ||
end | ||
|
||
subject { client.get_program_by_id(1107) } | ||
|
||
before do | ||
stub_request(:get, "https://#{host}/rest/asset/v1/program/1107.json") | ||
.to_return(json_stub(response_stub)) | ||
end | ||
|
||
it { is_expected.to eq(response_stub) } | ||
end | ||
end |