This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
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.
- Loading branch information
Showing
19 changed files
with
505 additions
and
58 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
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,47 @@ | ||
require 'desk_api/error/not_embeddable' | ||
|
||
module DeskApi | ||
module Action | ||
module Embeddable | ||
attr_reader :embedded | ||
|
||
def embed(*embedds) | ||
# make sure we don't try to embed anything that's not defined | ||
# add it to the query | ||
self.query_params = { embed: embedds.each{ |embed| | ||
unless self.base_class.embeddable?(embed) | ||
raise DeskApi::Error::NotEmbeddable.new("`#{embed.to_s}' can not be embedded.") | ||
end | ||
}.join(',') } | ||
# return self | ||
self | ||
end | ||
|
||
def setup_embedded(embedds) | ||
if embedds.entries? | ||
@records = embedds['entries'].map do |record| | ||
resource(record._links.self['class']).new(client, record, true) | ||
end | ||
else | ||
embedds.each_pair do |key, definition| | ||
@_links[key]['resource'] = resource(definition['class']).new @client, definition, true | ||
end | ||
end | ||
end | ||
|
||
module ClassMethods | ||
def embeddable(*embeddables) | ||
@embeddables = embeddables | ||
end | ||
|
||
def embeddable?(key) | ||
(@embeddables || []).include?(key.to_sym) | ||
end | ||
end | ||
|
||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
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,8 @@ | ||
require 'desk_api/error' | ||
|
||
module DeskApi | ||
class Error | ||
class NotEmbeddable < DeskApi::Error | ||
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
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,7 @@ | ||
module DeskApi | ||
class Resource | ||
class Filter < DeskApi::Resource | ||
embeddable :user, :group | ||
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,7 @@ | ||
module DeskApi | ||
class Resource | ||
class InboundMailbox < DeskApi::Resource | ||
embeddable :default_group | ||
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
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
54 changes: 54 additions & 0 deletions
54
spec/cassettes/DeskApi_Resource_Page/_find/has_an_alias_by_id.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 7 additions & 7 deletions
14
...e/_by_id/loads_the_requested_resource.yml → ...ge/_find/loads_the_requested_resource.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.