versacommerce-theme_api_client 0.1.3 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c58a3ccc7e4d17525a5a1d611cd4304ea1061287
4
- data.tar.gz: 88fbc74106783012399df78915249e87aff0fb4e
2
+ SHA256:
3
+ metadata.gz: 2475dfd16c9b90dd2a5d6d76a5611d39b188131152560698dbf7e215b0cac5e6
4
+ data.tar.gz: fe2ece15355542927dc8c3584c465b4a3c474e3a6d7e29abe1076f90ead03276
5
5
  SHA512:
6
- metadata.gz: a798ab3ec485c237f9f7097758db624285c3b6e342f3f0459fbb18572824e84a866230f3a131bdbc21a70c30f123fdb5b9639f41eb1a91390c3e7bfcfe11d423
7
- data.tar.gz: 5cc6eeb253aca9dcfc33656bff0ebdfb188570285a951afb6033498d445d09ea48f07739aa09cafe660646425b070ae6bb0578c47ac71eda1a885769cac4c83b
6
+ metadata.gz: 95bf32338399a00967aaa6e3454807e3563d5eaecc98761f14c0e80ad400c8c92252af7d8ab819a3215db2323b691898ff60fe7dec20f6678853f9c455e9cbde
7
+ data.tar.gz: 372c77b36a475243e133f48c0472b8c2acde9a752feee9f92ca923b641f00f8fa7011085d69434c6231d1896b3ddc2ae301e2715cf32d140886dda3bc441fd58
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.2] - 2025-10-30
9
+
10
+ ### Added
11
+ - SSL verification configuration option (`ssl_verify` attribute)
12
+ - Support for custom base URL configuration
13
+ - Comprehensive configuration documentation in README
14
+
15
+ ### Changed
16
+ - Default SSL verification is enabled (secure by default)
17
+ - Fetcher now respects `ssl_verify` setting when making HTTP requests
18
+
19
+ ## [1.0.1] - Previous Release
20
+
21
+ ### Changed
22
+ - Updated to Ruby 3.1+
23
+ - Loosened gem dependencies
data/CLAUDE.md ADDED
@@ -0,0 +1,104 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Ruby gem that provides an API client for the VersaCommerce Theme API. It allows developers to programmatically manage theme files and directories for VersaCommerce shops.
8
+
9
+ ## Requirements
10
+
11
+ - Ruby >= 3.3.0
12
+ - Dependencies: http (~> 5.0), activesupport (>= 4.2, < 8.0), activemodel (>= 4.2, < 8.0)
13
+
14
+ ## Common Commands
15
+
16
+ ### Setup and Development
17
+ ```bash
18
+ bin/setup # Install dependencies
19
+ bin/console # Launch interactive console for experimentation
20
+ bundle install # Install gem dependencies
21
+ ```
22
+
23
+ ### Building and Publishing
24
+ ```bash
25
+ rake build # Build the gem
26
+ rake install # Build and install gem locally
27
+ rake release # Create git tag, build and push gem to rubygems.org
28
+ ```
29
+
30
+ ## Architecture
31
+
32
+ ### Core Components
33
+
34
+ **Client (lib/versacommerce/theme_api_client.rb)**
35
+ - Entry point for the gem
36
+ - Initialized with authorization token
37
+ - Provides `directories()` and `files()` methods that return relation objects
38
+ - Configurable `base_url` (defaults to https://theme-api.versacommerce.de)
39
+ - Dynamically creates resource classes tied to the client instance
40
+
41
+ **Fetcher (lib/versacommerce/theme_api_client/fetcher.rb)**
42
+ - HTTP communication layer using the `http` gem
43
+ - Handles all HTTP verbs (GET, POST, PATCH, DELETE, HEAD)
44
+ - Adds Theme-Authorization header to all requests
45
+ - Defines custom errors: `RecordNotFoundError` and `UnauthorizedError`
46
+ - Extends HTTP::Response with a `json` method for parsing JSON responses
47
+
48
+ **Relation (lib/versacommerce/theme_api_client/relation.rb)**
49
+ - Base class for DirectoryRelation and FileRelation
50
+ - Implements Enumerable for iteration
51
+ - Provides ActiveRecord-like interface: `find()`, `build()`, `create()`, `delete()`
52
+ - Supports path scoping with `in_path()` method
53
+ - Handles recursive vs non-recursive queries
54
+
55
+ **Resource (lib/versacommerce/theme_api_client/resource.rb)**
56
+ - Base class for Directory and File resources
57
+ - Uses ActiveModel for validations and dirty tracking
58
+ - Implements `save()`, `update()`, `new_record?` methods
59
+ - Each resource class is dynamically created per client instance (see `directory_class` and `file_class` in client)
60
+
61
+ ### Resource Types
62
+
63
+ **Directory (lib/versacommerce/theme_api_client/resources/directory.rb)**
64
+ - Represents theme directories
65
+ - Has `path` attribute
66
+ - Provides `files()` method to access files within the directory
67
+
68
+ **File (lib/versacommerce/theme_api_client/resources/file.rb)**
69
+ - Represents theme files
70
+ - Has `path` and `content` attributes
71
+ - Content loading is conditional: text files load automatically, binary files require explicit `load_content: true`
72
+ - Provides `reload_content()` and `has_content?` methods
73
+
74
+ ### Key Design Patterns
75
+
76
+ **Dynamic Class Creation**: The client creates subclasses of Directory and File at runtime (via `directory_class` and `file_class`), binding them to the specific client instance. This allows each resource to access the client's fetcher and configuration.
77
+
78
+ **Relation Pattern**: Inspired by ActiveRecord, relations provide chainable query interfaces and lazy evaluation. The `in_path()` method modifies the relation's path scope without executing queries.
79
+
80
+ **Path Helpers**: The client provides `directory_path()`, `file_path()`, `download_path()`, and `tree_path()` helper methods that build Pathname objects for API endpoints.
81
+
82
+ ## Module Structure
83
+
84
+ ```
85
+ lib/versacommerce/
86
+ theme_api_client.rb # Main client class
87
+ theme_api_client/
88
+ client.rb # (Appears to be duplicate/alternative entry point)
89
+ fetcher.rb # HTTP client wrapper
90
+ relation.rb # Base relation class
91
+ resource.rb # Base resource class with ActiveModel
92
+ version.rb # Gem version constant
93
+ relations/
94
+ directory_relation.rb
95
+ file_relation.rb
96
+ resources/
97
+ directory.rb
98
+ file.rb
99
+ file_behaviour.rb # Shared file behavior module
100
+ ```
101
+
102
+ ## Testing
103
+
104
+ This gem does not appear to have a test suite in the repository. When adding tests, consider creating a spec/ or test/ directory.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 VersaCommerce
3
+ Copyright (c) 2025 VersaCommerce
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -6,7 +6,7 @@ Versacommerce::ThemeAPIClient is a library to consume the VersaCommerce Theme AP
6
6
 
7
7
  ## Requirements
8
8
 
9
- Ruby ≥ 2.0.0
9
+ Ruby ≥ 3.1.0
10
10
 
11
11
  ## Installation
12
12
 
@@ -41,6 +41,42 @@ client = Versacommerce::ThemeAPIClient.new(authorization: authorization)
41
41
 
42
42
  The client object is tied to a single theme, depending on the authorization. You can get an authorization from your shop's admin section.
43
43
 
44
+ ### Configuration Options
45
+
46
+ The client accepts the following configuration options:
47
+
48
+ ```ruby
49
+ client = Versacommerce::ThemeAPIClient.new(
50
+ authorization: 'YOUR_AUTHORIZATION', # Required: API authorization token
51
+ base_url: 'https://theme-api.versacommerce.de', # Optional: Custom API endpoint
52
+ ssl_verify: true # Optional: Enable/disable SSL certificate verification (default: true)
53
+ )
54
+ ```
55
+
56
+ #### SSL Verification
57
+
58
+ By default, SSL certificate verification is enabled. You can disable it for development/testing environments with self-signed certificates:
59
+
60
+ ```ruby
61
+ client = Versacommerce::ThemeAPIClient.new(
62
+ authorization: 'YOUR_AUTHORIZATION',
63
+ ssl_verify: false # Disable SSL verification (not recommended for production)
64
+ )
65
+ ```
66
+
67
+ **Warning:** Disabling SSL verification is not recommended for production environments.
68
+
69
+ #### Custom Base URL
70
+
71
+ If you need to connect to a different API endpoint (e.g., staging environment):
72
+
73
+ ```ruby
74
+ client = Versacommerce::ThemeAPIClient.new(
75
+ authorization: 'YOUR_AUTHORIZATION',
76
+ base_url: 'https://staging-theme-api.example.com'
77
+ )
78
+ ```
79
+
44
80
  ### Working with Directories
45
81
 
46
82
  #### Finding Directories
@@ -84,7 +84,17 @@ module Versacommerce
84
84
  end
85
85
 
86
86
  def with_headers
87
- HTTP.with_headers(accept: 'application/json', 'Theme-Authorization' => authorization)
87
+ http_client = HTTP.headers(accept: 'application/json', 'Theme-Authorization' => authorization)
88
+
89
+ # Apply SSL verification setting if explicitly disabled
90
+ unless client.ssl_verify
91
+ require 'openssl'
92
+ ssl_context = OpenSSL::SSL::SSLContext.new
93
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
94
+ http_client = http_client.use(ssl_context: ssl_context)
95
+ end
96
+
97
+ http_client
88
98
  end
89
99
  end
90
100
  end
@@ -73,7 +73,7 @@ module Versacommerce
73
73
 
74
74
  def delete
75
75
  unless new_record?
76
- response = fetcher.delete(file_path(path))
76
+ fetcher.delete(file_path(path))
77
77
  content_will_change!
78
78
  self.new_record = true
79
79
  end
@@ -94,7 +94,7 @@ module Versacommerce
94
94
  unless new_record?
95
95
  response = fetcher.get(download_path(path))
96
96
  self.content = response.to_s
97
- clear_attribute_changes(:content)
97
+ clear_attribute_changes([:content])
98
98
  end
99
99
 
100
100
  self
@@ -1,5 +1,5 @@
1
1
  module Versacommerce
2
2
  class ThemeAPIClient
3
- VERSION = Gem::Version.new('0.1.3')
3
+ VERSION = Gem::Version.new('1.0.2')
4
4
  end
5
5
  end
@@ -7,10 +7,12 @@ require 'versacommerce/theme_api_client/version'
7
7
 
8
8
  module Versacommerce
9
9
  class ThemeAPIClient
10
- attr_accessor :authorization
10
+ attr_accessor :authorization, :ssl_verify
11
11
  attr_writer :base_url, :fetcher
12
12
 
13
13
  def initialize(attributes = {})
14
+ @ssl_verify = true # Default to true (secure by default)
15
+
14
16
  attributes.each do |key, value|
15
17
  public_send("#{key}=", value)
16
18
  end
@@ -3,8 +3,7 @@ require_relative 'lib/versacommerce/theme_api_client/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'versacommerce-theme_api_client'
5
5
  spec.version = Versacommerce::ThemeAPIClient::VERSION
6
- spec.authors = ['Tobias Bühlmann']
7
- spec.email = ['buehlmann@versacommerce.de']
6
+ spec.authors = ['VersaCommerce GmbH']
8
7
 
9
8
  spec.summary = 'API Client for the VersaCommercer Theme API.'
10
9
  spec.description = 'This Gem acts as an API Client for the VersaCommerce Theme API.'
@@ -16,14 +15,14 @@ Gem::Specification.new do |spec|
16
15
  spec.executables = spec.files.grep(/\Aexe/) { |f| File.basename(f) }
17
16
  spec.require_paths = ['lib']
18
17
 
19
- spec.required_ruby_version = '>= 2.0.0'
18
+ spec.required_ruby_version = '>= 3.1.0'
20
19
 
21
- spec.add_runtime_dependency 'http', '>= 0.8.12', '< 1.0.0'
22
- spec.add_runtime_dependency 'activesupport', '~> 4.2'
23
- spec.add_runtime_dependency 'activemodel', '~> 4.2'
20
+ spec.add_runtime_dependency 'http', '~> 5.0'
21
+ spec.add_runtime_dependency 'activesupport', '>= 4.2', '< 7.0'
22
+ spec.add_runtime_dependency 'activemodel', '>= 4.2', '< 7.0'
24
23
 
25
- spec.add_development_dependency 'bundler', '~> 1.8'
26
- spec.add_development_dependency 'rake', '~> 10.4'
27
- spec.add_development_dependency 'pry', '0.10.1'
28
- spec.add_development_dependency 'pry-stack_explorer', '0.4.9.2'
24
+ spec.add_development_dependency 'bundler', '>= 1.8'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
+ spec.add_development_dependency 'pry', '~> 0.14'
27
+ spec.add_development_dependency 'pry-stack_explorer', '~> 0.6'
29
28
  end
metadata CHANGED
@@ -1,75 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versacommerce-theme_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - Tobias Bühlmann
8
- autorequire:
7
+ - VersaCommerce GmbH
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-18 00:00:00.000000000 Z
11
+ date: 2025-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.8.12
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 1.0.0
19
+ version: '5.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.8.12
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 1.0.0
26
+ version: '5.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activesupport
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - "~>"
31
+ - - ">="
38
32
  - !ruby/object:Gem::Version
39
33
  version: '4.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7.0'
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
43
40
  requirements:
44
- - - "~>"
41
+ - - ">="
45
42
  - !ruby/object:Gem::Version
46
43
  version: '4.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activemodel
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '4.2'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '7.0'
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">="
59
62
  - !ruby/object:Gem::Version
60
63
  version: '4.2'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '7.0'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: bundler
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
- - - "~>"
71
+ - - ">="
66
72
  - !ruby/object:Gem::Version
67
73
  version: '1.8'
68
74
  type: :development
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
- - - "~>"
78
+ - - ">="
73
79
  - !ruby/object:Gem::Version
74
80
  version: '1.8'
75
81
  - !ruby/object:Gem::Dependency
@@ -78,50 +84,52 @@ dependencies:
78
84
  requirements:
79
85
  - - "~>"
80
86
  - !ruby/object:Gem::Version
81
- version: '10.4'
87
+ version: '13.0'
82
88
  type: :development
83
89
  prerelease: false
84
90
  version_requirements: !ruby/object:Gem::Requirement
85
91
  requirements:
86
92
  - - "~>"
87
93
  - !ruby/object:Gem::Version
88
- version: '10.4'
94
+ version: '13.0'
89
95
  - !ruby/object:Gem::Dependency
90
96
  name: pry
91
97
  requirement: !ruby/object:Gem::Requirement
92
98
  requirements:
93
- - - '='
99
+ - - "~>"
94
100
  - !ruby/object:Gem::Version
95
- version: 0.10.1
101
+ version: '0.14'
96
102
  type: :development
97
103
  prerelease: false
98
104
  version_requirements: !ruby/object:Gem::Requirement
99
105
  requirements:
100
- - - '='
106
+ - - "~>"
101
107
  - !ruby/object:Gem::Version
102
- version: 0.10.1
108
+ version: '0.14'
103
109
  - !ruby/object:Gem::Dependency
104
110
  name: pry-stack_explorer
105
111
  requirement: !ruby/object:Gem::Requirement
106
112
  requirements:
107
- - - '='
113
+ - - "~>"
108
114
  - !ruby/object:Gem::Version
109
- version: 0.4.9.2
115
+ version: '0.6'
110
116
  type: :development
111
117
  prerelease: false
112
118
  version_requirements: !ruby/object:Gem::Requirement
113
119
  requirements:
114
- - - '='
120
+ - - "~>"
115
121
  - !ruby/object:Gem::Version
116
- version: 0.4.9.2
122
+ version: '0.6'
117
123
  description: This Gem acts as an API Client for the VersaCommerce Theme API.
118
124
  email:
119
- - buehlmann@versacommerce.de
120
125
  executables: []
121
126
  extensions: []
122
127
  extra_rdoc_files: []
123
128
  files:
124
129
  - ".gitignore"
130
+ - ".ruby-version"
131
+ - CHANGELOG.md
132
+ - CLAUDE.md
125
133
  - Gemfile
126
134
  - LICENSE.txt
127
135
  - README.md
@@ -144,7 +152,7 @@ homepage: https://github.com/versacommerce/versacommerce-theme_api_client
144
152
  licenses:
145
153
  - MIT
146
154
  metadata: {}
147
- post_install_message:
155
+ post_install_message:
148
156
  rdoc_options: []
149
157
  require_paths:
150
158
  - lib
@@ -152,16 +160,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
160
  requirements:
153
161
  - - ">="
154
162
  - !ruby/object:Gem::Version
155
- version: 2.0.0
163
+ version: 3.1.0
156
164
  required_rubygems_version: !ruby/object:Gem::Requirement
157
165
  requirements:
158
166
  - - ">="
159
167
  - !ruby/object:Gem::Version
160
168
  version: '0'
161
169
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.4.5
164
- signing_key:
170
+ rubygems_version: 3.3.26
171
+ signing_key:
165
172
  specification_version: 4
166
173
  summary: API Client for the VersaCommercer Theme API.
167
174
  test_files: []