Socket
Book a DemoInstallSign in
Socket

copy_ai

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy_ai

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

A Ruby interface to the Copy.ai Workflows API

Installation

Install the gem and add to the application's Gemfile:

bundle add copy_ai

Or, to install directly:

gem install copy_ai

Usage

First, obtain credentials from https://docs.copy.ai/reference/authentication.

require "copy_ai"

copy_ai_credentials = {
  api_key:              "INSERT YOUR X API KEY HERE",
  api_endpoint:         "INSERT YOUR X API ENDPOINT HERE"
}

# Initialize a API client with your Workspace Api Key
copy_ai_client = CopyAi::Client.new(**copy_ai_credentials)

# Register webhook
# url: your site webhook URL
# event_type: https://docs.copy.ai/reference/register-webhook#event-types
# optional workflow_id: If a workflow ID is not specified, you will receive events for all workflows in your workspace.
response = CopyAi::Webook.register(copy_ai_client, url: 'https://cloud-asm.com/webhook', event_type: 'workflowRun.completed', workflow_id: <workflow-id>)
# {
    "status": "success",
    "data": {
      "id": "<id of webhook>",
      "url": "<https://mywebsite.com/webhook>",
      "eventType": "workflowRun.completed",
      "workflowId": "<workflow-id>"
    }
  }

# Starting a Workflow Run
post = copy_ai_client.post(body: {
  startVariables: {
	  "Input 1": "<Inputs vary depending on the workflow used.>",
	  "Input 2": "<The best way to see an example is to try it!>"
	},
	"metadata": {
    "api": true
	}
})
# { "status": "success", "data": { "id": "<run-id>" } }

# Tracking / Poll for Progress
copy_ai_client.get
# {
    "status": "success",
    "data":
    {
      "id": "<run-id>",
      "input":
      { 
        "Input 1": "Inputs vary depending on the workflow used.",
        "Input 2": "The best way to see an example is to try it!" 
      },
      "status": "PROCESSING",
      "output":
      {
        "Output 1": "<Outputs vary depending on the workflow used.>",
        "Output 2": "<The best way to see an example is to try it!>"
      },
      "createdAt": "2022-11-18T20:30:07.434Z"
    }
  }

# Run Completion
# When the run is complete, the status will change to COMPLETE and a POST request will be sent to the registered webhooks to notify of the workflow's completion.
# {
    "type": "workflowRun.completed",
    "workflowRunId": "<run-id>",
    "workflowId": "<workflow-id>",
    "result":
    {
      "Output 1": "<Outputs vary depending on the workflow used.>",
      "Output 2": "<The best way to see an example is to try it!>"
    },
    "metadata":
    {
      /* any metadata set on the workflow run */
    },
    "credits": 2 
  }

Development

  • Checkout and repo:

    git checkout git@github.com:wwwfernand/copy_ai.git
    
  • Enter the repo's directory:

    cd copy_ai
    
  • Install dependencies via Bundler:

    bundle install
    
  • Run the default Rake task to ensure all tests pass:

    bundle exec rake
    
  • Create a new branch for your feature or bug fix:

    git checkout -b my-new-branch
    

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/wwwfernand/copy_ai.

Pull requests will only be accepted if they meet all the following criteria:

  • Code must conform to Standard Ruby.

    bundle exec rake standard
    
  • Code must conform to the RuboCop rules.

    bundle exec rake rubocop
    
  • 100% LOC code coverage.

    bundle exec rake test
    
  • 100% mutation coverage.

    bundle exec rake mutant
    
  • RBS type signatures (in sig/copy_ai.rbs).

    bundle exec rake steep
    

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 19 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.