Class: Locomotive::Coal::Client
- Inherits:
-
Object
- Object
- Locomotive::Coal::Client
- Defined in:
- lib/locomotive/coal/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #accounts ⇒ Object
- #content_assets ⇒ Object
- #content_entries(content_type) ⇒ Object
- #content_types ⇒ Object (also: #contents)
- #current_site ⇒ Object
- #engine_version ⇒ Object (also: #version)
-
#initialize(uri, credentials, options = {}) ⇒ Client
constructor
A new instance of Client.
- #memberships ⇒ Object
- #my_account ⇒ Object
- #pages ⇒ Object
- #reset ⇒ Object
- #scope_by(site_or_handle) ⇒ Object
- #sections ⇒ Object
- #sites ⇒ Object
- #snippets ⇒ Object
- #ssl? ⇒ Boolean
- #theme_assets ⇒ Object
- #token ⇒ Object
- #translations ⇒ Object
Constructor Details
#initialize(uri, credentials, options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 |
# File 'lib/locomotive/coal/client.rb', line 7 def initialize(uri, credentials, = {}) if uri.blank? || credentials.blank? raise MissingURIOrCredentialsError.new('URI and/or credentials are missing') else @options = { path_prefix: 'locomotive' }.merge().with_indifferent_access @uri, @credentials = prepare_uri(uri), credentials.with_indifferent_access end end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
5 6 7 |
# File 'lib/locomotive/coal/client.rb', line 5 def credentials @credentials end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/locomotive/coal/client.rb', line 5 def @options end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/locomotive/coal/client.rb', line 5 def uri @uri end |
Instance Method Details
#accounts ⇒ Object
24 25 26 |
# File 'lib/locomotive/coal/client.rb', line 24 def accounts @accounts ||= Resources::Accounts.new(uri, connection) end |
#content_assets ⇒ Object
55 56 57 |
# File 'lib/locomotive/coal/client.rb', line 55 def content_assets @content_assets ||= Resources::ContentAssets.new(uri, connection) end |
#content_entries(content_type) ⇒ Object
50 51 52 53 |
# File 'lib/locomotive/coal/client.rb', line 50 def content_entries(content_type) @content_entries ||= {} @content_entries[content_type.slug] ||= Resources::ContentEntries.new(uri, connection, content_type) end |
#content_types ⇒ Object Also known as: contents
44 45 46 |
# File 'lib/locomotive/coal/client.rb', line 44 def content_types @content_types ||= Resources::ContentTypes.new(uri, connection) end |
#current_site ⇒ Object
36 37 38 |
# File 'lib/locomotive/coal/client.rb', line 36 def current_site @current_site ||= Resources::CurrentSite.new(uri, connection) end |
#engine_version ⇒ Object Also known as: version
75 76 77 |
# File 'lib/locomotive/coal/client.rb', line 75 def engine_version @engine_version ||= Resources::EngineVersion.new(uri, connection).version end |
#memberships ⇒ Object
32 33 34 |
# File 'lib/locomotive/coal/client.rb', line 32 def memberships @memberships ||= Resources::Memberships.new(uri, connection) end |
#my_account ⇒ Object
20 21 22 |
# File 'lib/locomotive/coal/client.rb', line 20 def my_account @my_account ||= Resources::MyAccount.new(uri, connection) end |
#pages ⇒ Object
40 41 42 |
# File 'lib/locomotive/coal/client.rb', line 40 def pages @pages ||= Resources::Pages.new(uri, connection) end |
#reset ⇒ Object
89 90 91 |
# File 'lib/locomotive/coal/client.rb', line 89 def reset @token = @my_account = @sites = @current_site = @pages = @content_types = @theme_assets = @content_assets = @translations = nil end |
#scope_by(site_or_handle) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/locomotive/coal/client.rb', line 81 def scope_by(site_or_handle) if site_or_handle.respond_to?(:handle) @current_site, site_or_handle = site_or_handle, site_or_handle.handle end [:handle] = site_or_handle self end |
#sections ⇒ Object
67 68 69 |
# File 'lib/locomotive/coal/client.rb', line 67 def sections @sections ||= Resources::Sections.new(uri, connection) end |
#sites ⇒ Object
28 29 30 |
# File 'lib/locomotive/coal/client.rb', line 28 def sites @sites ||= Resources::Sites.new(uri, connection) end |
#snippets ⇒ Object
63 64 65 |
# File 'lib/locomotive/coal/client.rb', line 63 def snippets @snippets ||= Resources::Snippets.new(uri, connection) end |
#ssl? ⇒ Boolean
93 94 95 |
# File 'lib/locomotive/coal/client.rb', line 93 def ssl? !!self.[:ssl] end |
#theme_assets ⇒ Object
59 60 61 |
# File 'lib/locomotive/coal/client.rb', line 59 def theme_assets @theme_assets ||= Resources::ThemeAssets.new(uri, connection) end |
#token ⇒ Object
16 17 18 |
# File 'lib/locomotive/coal/client.rb', line 16 def token @token ||= Resources::Token.new(uri, credentials).get end |
#translations ⇒ Object
71 72 73 |
# File 'lib/locomotive/coal/client.rb', line 71 def translations @translations ||= Resources::Translations.new(uri, connection) end |