runapi-recraft 0.2.6 → 0.2.7

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
2
  SHA256:
3
- metadata.gz: 55e7e0c96e8835ade78091ac2ae8730b97243801959c50b770025cff53c7819f
4
- data.tar.gz: 9da9fd4900070f8b49748c3f6f8a8b9fd7b8637469c6efe144921592e430080e
3
+ metadata.gz: 477bd23affda1ef60acfcd9d9add3cbfb216c0e8fe9ecaca17bfa053077cd144
4
+ data.tar.gz: d754513ee14f79f3af3e94658994b5d5128f9775dabbbc9f57b1e75ac18a20e0
5
5
  SHA512:
6
- metadata.gz: 100bc2fe7dbfc4c66fa4b083c646fdf6aa629c8f83bf55b038351bcb74ff28d6e0395b5e290e9df26ea2bc5b01e769684c9492d808ecb24537dd956e41a6c5bf
7
- data.tar.gz: c611577ce0b679934f79729968fa5bf38d8597406b6805d709f0029d48f01fcbaaf2481096fe3a65c0fd967a54e651039f1d31a0e23c338b11d794621d596264
6
+ metadata.gz: 2ef6f4ecaafd2a69e537fd2acdbabde0b2fb5623b2d12ce8dc589b196019b8626a0c3c60df77a07b32c14563f9b5dda7603d4380bcd13457013ded2463cf711a
7
+ data.tar.gz: fb15f2bd59d56d4316095e2e1e29a71e3be9fa80bc791a69d0fa8358aaacaf6eb1dc769c5b707357bccf8e2718e092d1ac6ee0a8c979c660785e91e46b204125
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Recraft API Ruby SDK for RunAPI
1
+ # Recraft Ruby SDK for RunAPI
2
2
 
3
- The recraft api Ruby SDK is the language-specific package for Recraft on RunAPI. Use this recraft api package for text-to-image, image editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The Recraft Ruby SDK is the language-specific package for Recraft on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
- This recraft api README is the Ruby package guide inside the public `recraft-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/recraft; for API reference, use https://runapi.ai/docs#recraft; for SDK docs, use https://runapi.ai/docs#sdk-recraft.
5
+ This README is the Ruby package guide inside the public `recraft-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/recraft; for API reference, use https://runapi.ai/docs#recraft; for SDK docs, use https://runapi.ai/docs#sdk-recraft.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,10 +16,10 @@ gem install runapi-recraft
16
16
  require "runapi-recraft"
17
17
 
18
18
  client = RunApi::Recraft::Client.new
19
- task = client.upscales.create(
19
+ task = client.upscale_image.create(
20
20
  # Pass the Recraft JSON request body from https://runapi.ai/docs#recraft.
21
21
  )
22
- status = client.upscales.get(task.id)
22
+ status = client.upscale_image.get(task.id)
23
23
  ```
24
24
 
25
25
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
31
- Use Ruby keyword arguments and the `RunApi::Recraft` error classes when building image jobs, Rails workers, or scripts. The available resources include upscales, and background removals. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
31
+ Use Ruby keyword arguments and the `RunApi::Recraft` error classes when building image jobs, Rails workers, or scripts. The available resources are `upscale_image` and `remove_background`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
@@ -11,12 +11,12 @@ module RunApi
11
11
  #
12
12
  # upscaled = client.upscale_image.run(
13
13
  # model: "recraft-crisp-upscale",
14
- # source_image_url: "https://example.com/photo.jpg"
14
+ # source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg"
15
15
  # )
16
16
  #
17
17
  # cutout = client.remove_background.run(
18
18
  # model: "recraft-remove-background",
19
- # source_image_url: "https://example.com/photo.jpg"
19
+ # source_image_url: "https://cdn.runapi.ai/public/samples/image.jpg"
20
20
  # )
21
21
  class Client < RunApi::Core::Client
22
22
  # @return [Resources::UpscaleImage] AI-powered image upscaling operations.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Recraft
5
+ CONTRACT = {
6
+ "remove-background" => {
7
+ "models" => ["recraft-remove-background"],
8
+ "fields_by_model" => {
9
+ "recraft-remove-background" => {
10
+ "source_image_url" => {
11
+ "required" => true
12
+ }
13
+ }
14
+ }
15
+ },
16
+ "upscale-image" => {
17
+ "models" => ["recraft-crisp-upscale"],
18
+ "fields_by_model" => {
19
+ "recraft-crisp-upscale" => {
20
+ "source_image_url" => {
21
+ "required" => true
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }.freeze
27
+ end
28
+ end
@@ -24,25 +24,13 @@ module RunApi
24
24
 
25
25
  def create(**params)
26
26
  params = compact_params(params)
27
- validate_params!(params)
27
+ validate_contract!(CONTRACT["remove-background"], params)
28
28
  request(:post, ENDPOINT, body: params)
29
29
  end
30
30
 
31
31
  def get(id)
32
32
  request(:get, "#{ENDPOINT}/#{id}")
33
33
  end
34
-
35
- private
36
-
37
- def validate_params!(params)
38
- raise Core::ValidationError, "model is required" unless param(params, :model)
39
- raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
40
-
41
- model = param(params, :model)
42
- unless Types::REMOVE_BACKGROUND_MODELS.include?(model)
43
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::REMOVE_BACKGROUND_MODELS.join(", ")}"
44
- end
45
- end
46
34
  end
47
35
  end
48
36
  end
@@ -24,25 +24,13 @@ module RunApi
24
24
 
25
25
  def create(**params)
26
26
  params = compact_params(params)
27
- validate_params!(params)
27
+ validate_contract!(CONTRACT["upscale-image"], params)
28
28
  request(:post, ENDPOINT, body: params)
29
29
  end
30
30
 
31
31
  def get(id)
32
32
  request(:get, "#{ENDPOINT}/#{id}")
33
33
  end
34
-
35
- private
36
-
37
- def validate_params!(params)
38
- raise Core::ValidationError, "model is required" unless param(params, :model)
39
- raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
40
-
41
- model = param(params, :model)
42
- unless Types::UPSCALE_IMAGE_MODELS.include?(model)
43
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::UPSCALE_IMAGE_MODELS.join(", ")}"
44
- end
45
- end
46
34
  end
47
35
  end
48
36
  end
@@ -4,11 +4,6 @@ module RunApi
4
4
  module Recraft
5
5
  # Type definitions and constants for the Recraft image processing API.
6
6
  module Types
7
- # Crisp upscaling model that enhances resolution while preserving detail.
8
- UPSCALE_IMAGE_MODELS = %w[recraft-crisp-upscale].freeze
9
- # Background removal model that isolates the foreground subject.
10
- REMOVE_BACKGROUND_MODELS = %w[recraft-remove-background].freeze
11
-
12
7
  # URL to a processed image (upscaled or background-removed).
13
8
  class Image < RunApi::Core::BaseModel
14
9
  optional :url, String
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "recraft/types"
4
+ require_relative "recraft/contract_gen"
4
5
  require_relative "recraft/resources/upscale_image"
5
6
  require_relative "recraft/resources/remove_background"
6
7
  require_relative "recraft/client"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-recraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,18 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.2.7
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.6
26
- description: The recraft api Ruby SDK is the language-specific package for Recraft
27
- on RunAPI. Use this recraft api package for text-to-image, image editing, and creative
28
- production flows when your application needs JSON request bodies, task status lookup,
29
- and consistent RunAPI errors in Ruby.
25
+ version: 0.2.7
26
+ description: The Recraft Ruby SDK is the language-specific package for Recraft on
27
+ RunAPI. Use this package for image generation, image editing, and creative production
28
+ workflows when your application needs request bodies, task status lookup, and consistent
29
+ RunAPI errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - lib/runapi-recraft.rb
40
40
  - lib/runapi/recraft.rb
41
41
  - lib/runapi/recraft/client.rb
42
+ - lib/runapi/recraft/contract_gen.rb
42
43
  - lib/runapi/recraft/resources/remove_background.rb
43
44
  - lib/runapi/recraft/resources/upscale_image.rb
44
45
  - lib/runapi/recraft/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/recraft
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: recraft
49
51
  homepage_uri: https://runapi.ai/models/recraft
50
52
  documentation_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/recraft-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/recraft-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/recraft-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements: []
67
70
  rubygems_version: 4.0.10
68
71
  specification_version: 4
69
- summary: Recraft API Ruby SDK for RunAPI
72
+ summary: Recraft Ruby SDK for RunAPI
70
73
  test_files: []