promptjoy-ruby 0.1.2 → 0.1.3

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: 07d9f4901a15071b45a7217e3b5ce7d512e0919d99cc412ed67313aedb5284d4
4
- data.tar.gz: 31b4ac60ade434071b796c3065c04d78bae9194f169a04f5fda7f042e37944d7
3
+ metadata.gz: b5cbf24cd878b9fd62c664a1033aa5961b8768e06069d40f85234e1e25d4210c
4
+ data.tar.gz: '0958ab3a92dc55778900be7a785b2d32818dd5b0b8eca6414b27b00a901039e7'
5
5
  SHA512:
6
- metadata.gz: c46105cdd2595b8ef283bb2fb0af5f440890d852d1da031bc8372e6b619d570c6a42efacdb11c3489089618a2748da842ef99488346e8ddc00985c93f01469b0
7
- data.tar.gz: bf1e89a3184ca54373852c5c9a1dec5ee89b324546c2f1a11f442985a964f6d2d9f7bbfef435e0670f8f896a160df87d8aea6707bb1f62f3beaefe555882fc19
6
+ metadata.gz: a6d4d61af49df233f084f955ff22fa58df79f61e4d533613b94f80fb8ac64443c98863088356b130b71f4dd8fa7ef7af0bc5475b4b9917e26d3805c69afb6b4d
7
+ data.tar.gz: 1500f2211ce37c87d590a26810dcdc0cf8341a4019ca5340d51141ff9cb19590106a3913d8096522d1b70a67e61cdc20cacbf9965265584f8c0c21a7c63bd621
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- promptjoy-ruby (0.1.2)
4
+ promptjoy-ruby (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,7 +2,14 @@
2
2
 
3
3
  Welcome to the official Ruby client for the [PromptJoy](https://promptjoy.com).
4
4
 
5
- PromptJoy is a platform that enables you to build scalable APIs by simply describing what you want. This client helps you interact with PromptJoy in a Ruby-friendly way.
5
+ [PromptJoy](https://promptjoy.com) is a platform that enables you to build scalable APIs by simply describing what you want.
6
+
7
+ Example APIs built on [PromptJoy](https://promptjoy.com):
8
+ * Travel recommendation https://promptjoy.com/apis/mPBCOr
9
+ * TV show -> podcast recommendation: https://promptjoy.com/apis/mxqCWW
10
+ * Schema transformation: https://promptjoy.com/apis/jn8Cep
11
+ * Book search engine: https://promptjoy.com/apis/mVMCpq
12
+
6
13
 
7
14
  ## Installation
8
15
 
@@ -36,12 +43,16 @@ client = PromptjoyRuby::Client.new('your_api_key')
36
43
 
37
44
  ```
38
45
 
39
- You can find the API you want to interact with by using its URL:
46
+ You can find the API you want to interact with by using its URL. You can find the URL in the endpoint field of the API's page:
40
47
 
41
48
  ```ruby
42
- api = client.find_by_api_url('https://api.promptjoy.com/test-endpoint')
49
+ api = client.find_by_api_url('https://api.promptjoy.com/api/id')
43
50
  ```
44
51
 
52
+ You can also just find the API by its id:
53
+ ```ruby
54
+ api = client.find('id')
55
+ ```
45
56
 
46
57
 
47
58
  To call the API, pass in the data as a Hash:
@@ -53,6 +64,20 @@ response = api.call({
53
64
  })
54
65
  ```
55
66
 
67
+ ## Example
68
+
69
+ The following example uses PromptJoy to build an API that recommends an open-source software package based on a problem to be solved: https://promptjoy.com/apis/jNqC7A
70
+
71
+ ``` ruby
72
+ > require 'promptjoy-ruby'
73
+ > client = PromptjoyRuby::Client.new('***********************')
74
+ > api = client.find_by_api_url('https://api.promptjoy.com/api/jNqC7A')
75
+ > response = api.call({problem: "queue processing in ruby"})
76
+ > puts response
77
+
78
+ {"software"=>"Sidekiq", "reason"=>"Efficient and reliable background processing
79
+ for Ruby", "github_url"=>"https://github.com/mperham/sidekiq"}
80
+ ```
56
81
 
57
82
 
58
83
  ## Error Handling
@@ -1,3 +1,3 @@
1
1
  module PromptjoyRuby
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -12,7 +12,7 @@ module PromptjoyRuby
12
12
  class Client
13
13
  BASE_API_URL = "https://api.promptjoy.com"
14
14
 
15
- def initialize(api_key = nil, logger: Logger.new(STDOUT))
15
+ def initialize(api_key = nil, logger: Logger.new(STDOUT), timeout: 120)
16
16
  @api_key = api_key
17
17
  @logger = logger
18
18
  end
@@ -30,7 +30,7 @@ module PromptjoyRuby
30
30
  class Api
31
31
  USER_AGENT = "PromptjoyRubyGem/#{PromptjoyRuby::VERSION}"
32
32
 
33
- def initialize(api_key, url, logger: Logger.new(STDOUT))
33
+ def initialize(api_key, url, logger: Logger.new(STDOUT), timeout: 120)
34
34
  @api_key = api_key
35
35
  @url = url
36
36
  @logger = logger
@@ -39,7 +39,9 @@ module PromptjoyRuby
39
39
  def call(api_data, client_ip = nil, referrer = nil)
40
40
  uri = URI(@url)
41
41
  http = Net::HTTP.new(uri.host, uri.port)
42
-
42
+ http.open_timeout = @timeout
43
+ http.read_timeout = @timeout
44
+
43
45
  if uri.scheme == 'https'
44
46
  http.use_ssl = true
45
47
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promptjoy-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PromptJoy Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-19 00:00:00.000000000 Z
11
+ date: 2023-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec