Class: Versacommerce::ThemeAPIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/versacommerce/theme_api_client.rb,
lib/versacommerce/theme_api_client/client.rb,
lib/versacommerce/theme_api_client/fetcher.rb,
lib/versacommerce/theme_api_client/version.rb,
lib/versacommerce/theme_api_client/relation.rb,
lib/versacommerce/theme_api_client/resource.rb,
lib/versacommerce/theme_api_client/resources/file.rb,
lib/versacommerce/theme_api_client/resources/directory.rb,
lib/versacommerce/theme_api_client/relations/file_relation.rb,
lib/versacommerce/theme_api_client/resources/file_behaviour.rb,
lib/versacommerce/theme_api_client/relations/directory_relation.rb

Defined Under Namespace

Modules: Relations, Resources Classes: Fetcher, Relation, Resource

Constant Summary collapse

VERSION =
Gem::Version.new('0.1.3')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) {|_self| ... } ⇒ ThemeAPIClient

Returns a new instance of ThemeAPIClient.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
# File 'lib/versacommerce/theme_api_client.rb', line 13

def initialize(attributes = {})
  attributes.each do |key, value|
    public_send("#{key}=", value)
  end

  yield(self) if block_given?
end

Instance Attribute Details

#authorizationObject

Returns the value of attribute authorization.



10
11
12
# File 'lib/versacommerce/theme_api_client.rb', line 10

def authorization
  @authorization
end

#base_urlObject



21
22
23
# File 'lib/versacommerce/theme_api_client.rb', line 21

def base_url
  @base_url || 'https://theme-api.versacommerce.de'
end

#fetcherObject



41
42
43
# File 'lib/versacommerce/theme_api_client.rb', line 41

def fetcher
  @fetcher ||= Fetcher.new(self)
end

Instance Method Details

#directories(path: '', recursive: true) ⇒ Object



25
26
27
# File 'lib/versacommerce/theme_api_client.rb', line 25

def directories(path: '', recursive: true)
  Relations::DirectoryRelation.new(self, path: path, recursive: recursive)
end

#directory_classObject



29
30
31
# File 'lib/versacommerce/theme_api_client.rb', line 29

def directory_class
  @directory_class ||= Class.new(Resources::Directory).tap { |dir| dir.client = self }
end

#directory_path(path = '') ⇒ Object



45
46
47
# File 'lib/versacommerce/theme_api_client.rb', line 45

def directory_path(path = '')
  Pathname.new('directories').join(path)
end

#download_path(path = '') ⇒ Object



53
54
55
# File 'lib/versacommerce/theme_api_client.rb', line 53

def download_path(path = '')
  Pathname.new('download').join(path)
end

#file_classObject



37
38
39
# File 'lib/versacommerce/theme_api_client.rb', line 37

def file_class
  @file_class ||= Class.new(Resources::File).tap { |dir| dir.client = self }
end

#file_path(path = '') ⇒ Object



49
50
51
# File 'lib/versacommerce/theme_api_client.rb', line 49

def file_path(path = '')
  Pathname.new('files').join(path)
end

#files(path: '', recursive: true) ⇒ Object



33
34
35
# File 'lib/versacommerce/theme_api_client.rb', line 33

def files(path: '', recursive: true)
  Relations::FileRelation.new(self, path: path, recursive: recursive)
end

#tree_path(path = '') ⇒ Object



57
58
59
# File 'lib/versacommerce/theme_api_client.rb', line 57

def tree_path(path = '')
  Pathname.new('tree').join(path)
end