wit 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: db82d7c5e9dad4d0566d3bd8bb047954bec32e8b
4
- data.tar.gz: 40cbef76d441b36725adfbfe30b31c3271b231aa
2
+ SHA256:
3
+ metadata.gz: 1a15b6f521d5b67b3c2d512e1ea9262ef4b1e39109e22eb9822a10aabe8e7b34
4
+ data.tar.gz: 6fd43d27a1edc8ccba793c45ca0fac4e90f9c27d265b3a105135e1bfb85b707e
5
5
  SHA512:
6
- metadata.gz: 2eafba1307cd42ecdf78358e64caf018b90fe7065c90e61f38758b3e6abfd56a0d668a193ed54f4b87648c6435df0c9c6f9dc22de4064037266b3dbba7eb0ac2
7
- data.tar.gz: 2cfdfddd281f45dd45f32eddd37df3dfcc2bad3064ee3acdf0e4109ddbb793a4bdd6617dc892280de1207640496c00fcdd64c097dfbf43d5d5cb4c133fb097d1
6
+ metadata.gz: eed12472514c8efdcbf6716b637aed58820dd98c437703566c027a10b57dca54877011d02dbc173e326aad8f7fa6a7d6c28ca499161070a73b913e73d840b650
7
+ data.tar.gz: 6d6f64a64117a9fd39ba9eb6074e3b7dc17bad80e48382930ea21f4584b2a1c96b5289df4ffdc6623ab8691d10c4af515f112551fd8e787184dec83e8fa01091
@@ -0,0 +1,9 @@
1
+ **Do you want to request a *feature*, report a *bug*, or ask a *question* about wit-ruby?**
2
+
3
+ **What is the current behavior?**
4
+
5
+ **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.**
6
+
7
+ **What is the expected behavior?**
8
+
9
+ **If applicable, what is the App ID where you are experiencing this issue? If you do not provide this, we cannot help.**
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v7.0.0
2
+ - Updated API version to latest: `20200513`. Browse the latest HTTP API documentation [here](https://wit.ai/docs/http/20200513#get__message_link).
3
+ - Added intents and traits CRUD methods.
4
+ - More consistent, transparent naming of entities methods.
5
+
1
6
  ## v6.0.0
2
7
  The most important change is the removal of `.converse()` and `.run_actions()`. Follow the migration tutorial [here](https://github.com/wit-ai/wit-stories-migration-tutorial), or [read more here](https://wit.ai/blog/2017/07/27/sunsetting-stories).
3
8
 
@@ -0,0 +1,76 @@
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to make participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all project spaces, and it also applies when
49
+ an individual is representing the project or its community in public spaces.
50
+ Examples of representing a project or community include using an official
51
+ project e-mail address, posting via an official social media account, or acting
52
+ as an appointed representative at an online or offline event. Representation of
53
+ a project may be further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at <opensource-conduct@fb.com>. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -0,0 +1,34 @@
1
+ # Contributing to wit-ruby
2
+
3
+ We want to make contributing to this project as easy and transparent as
4
+ possible.
5
+
6
+ ## Pull Requests
7
+ We actively welcome your pull requests.
8
+
9
+ 1. Fork the repo and create your branch from `master`.
10
+ 2. If you've added code that should be tested, add tests.
11
+ 3. If you've changed APIs, update the documentation.
12
+ 4. Ensure the test suite passes.
13
+ 5. If you haven't already, complete the Contributor License Agreement ("CLA").
14
+
15
+ ## Contributor License Agreement ("CLA")
16
+
17
+ In order to accept your pull request, we need you to submit a CLA. You only need
18
+ to do this once to work on any of Facebook's open source projects.
19
+
20
+ Complete your CLA here: <https://code.facebook.com/cla>
21
+
22
+ ## Issues
23
+
24
+ We use GitHub issues to track public bugs. Please ensure your description is
25
+ clear and has sufficient instructions to be able to reproduce the issue.
26
+
27
+ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
28
+ disclosure of security bugs. In those cases, please go through the process
29
+ outlined on that page and do not file a public issue.
30
+
31
+ ## License
32
+
33
+ By contributing to wit-ruby, you agree that your contributions will be licensed
34
+ under the LICENSE file in the root directory of this source tree.
data/README.md CHANGED
@@ -31,7 +31,7 @@ See the `examples` folder for more examples.
31
31
  ### Overview
32
32
 
33
33
  `wit-ruby` provides a Wit class with the following methods:
34
- * `message` - the Wit [message API](https://wit.ai/docs/http/20160330#get-intent-via-text-link)
34
+ * `message` - the Wit [message API](https://wit.ai/docs/http/20200513#get-intent-via-text-link)
35
35
  * `interactive` - starts an interactive conversation with your bot
36
36
 
37
37
  ### Wit class
@@ -49,7 +49,7 @@ client.message('set an alarm tomorrow at 7am')
49
49
 
50
50
  ### .message()
51
51
 
52
- The Wit [message API](https://wit.ai/docs/http/20160330#get-intent-via-text-link).
52
+ The Wit [message API](https://wit.ai/docs/http/20200513#get-intent-via-text-link).
53
53
 
54
54
  Takes the following parameters:
55
55
  * `msg` - the text you want Wit.ai to extract the information from
@@ -69,44 +69,91 @@ Example:
69
69
  client.interactive
70
70
  ```
71
71
 
72
+ ### CRUD operations for intents
73
+ `payload` in the parameters is a hash containing API arguments.
74
+
75
+ #### .get_intents()
76
+ Returns a list of available intents for the app.
77
+ See [GET /intents](https://wit.ai/docs/http/20200513#get__intents_link).
78
+
79
+ #### .get_intent(intent)
80
+ Returns all available information about an intent.
81
+ See [GET /intents/:intent](https://wit.ai/docs/http/20200513#get__intents__intent_link).
82
+
83
+ #### .post_intents(payload)
84
+ Creates a new intent.
85
+ See [POST /intents](https://wit.ai/docs/http/20200513#post__intents_link).
86
+
87
+ #### .delete_intents(intent)
88
+ Permanently deletes the intent.
89
+ See [DELETE /intents/:intent](https://wit.ai/docs/http/20200513#delete__intents__intent_link).
90
+
72
91
  ### CRUD operations for entities
73
- payload in the parameters is a hash containing API arguments
92
+ `payload` in the parameters is a hash containing API arguments.
74
93
 
75
94
  #### .get_entities()
76
95
  Returns a list of available entities for the app.
77
- See [GET /entities](https://wit.ai/docs/http/20160526#get--entities-link)
96
+ See [GET /entities](https://wit.ai/docs/http/20200513#get--entities-link)
78
97
 
79
98
  #### .post_entities(payload)
80
99
  Creates a new entity with the given attributes.
81
- See [POST /entities](https://wit.ai/docs/http/20160526#post--entities-link)
100
+ See [POST /entities](https://wit.ai/docs/http/20200513#post--entities-link)
82
101
 
83
- #### .get_entity(entity_id)
84
- Returns all the expressions validated for an entity.
85
- See [GET /entities/:entity-id](https://wit.ai/docs/http/20160526#get--entities-:entity-id-link)
102
+ #### .get_entity(entity)
103
+ Returns all the information available for an entity.
104
+ See [GET /entities/:entity](https://wit.ai/docs/http/20200513#get--entities-:entity-link)
86
105
 
87
- #### .put_entities(entity_id, payload)
106
+ #### .put_entities(entity, payload)
88
107
  Updates an entity with the given attributes.
89
- See [PUT /entities/:entity-id](https://wit.ai/docs/http/20160526#put--entities-:entity-id-link)
108
+ See [PUT /entities/:entity](https://wit.ai/docs/http/20200513#put--entities-:entity-link)
109
+
110
+ #### .delete_entities(entity)
111
+ Permanently removes the entity.
112
+ See [DELETE /entities/:entity](https://wit.ai/docs/http/20200513#delete--entities-:entity-link)
113
+
114
+ #### .post_entities_keywords(entity, payload)
115
+ Adds a possible value into the list of keywords for the keywords entity.
116
+ See [POST /entities/:entity/keywords](https://wit.ai/docs/http/20160526#post--entities-:entity-id-values-link)
117
+
118
+ #### .delete_entities_keywords(entity, keyword)
119
+ Deletes a keyword from the entity.
120
+ See [DELETE /entities/:entity/keywords/:keyword](https://wit.ai/docs/http/20200513#delete--entities-:entity-keywords-link)
121
+
122
+ #### .post_entities_keywords_synonyms(entity, keyword, payload)
123
+ Creates a new synonym for the keyword of the entity.
124
+ See [POST /entities/:entity/keywords/:keyword/synonyms](https://wit.ai/docs/http/20200513#post--entities-:entity-keywords-:keyword-synonyms-link)
125
+
126
+ #### delete_entities_keywords_synonyms(entity, keyword, synonym)
127
+ Deletes a synonym of the keyword of the entity.
128
+ See [DELETE /entities/:entity/keywords/:keyword/synonyms/:synonym](https://wit.ai/docs/http/20200513#delete--entities-:entity-keywords-:keyword-synonyms-link)
129
+
130
+ ### CRUD operations for traits
131
+ `payload` in the parameters is a hash containing API arguments.
90
132
 
91
- #### .delete_entities(entity_id)
92
- Permanently remove the entity.
93
- See [DELETE /entities/:entity-id](https://wit.ai/docs/http/20160526#delete--entities-:entity-id-link)
133
+ #### .get_traits()
134
+ Returns a list of available traits for the app.
135
+ See [GET /traits](https://wit.ai/docs/http/20200513#get__traits_link).
94
136
 
95
- #### .post_values(entity_id, payload)
96
- Add a possible value into the list of values for the entity.
97
- See [POST /entities/:entity-id/values](https://wit.ai/docs/http/20160526#post--entities-:entity-id-values-link)
137
+ #### .get_trait(trait)
138
+ Returns all available information about a trait.
139
+ See [GET /traits/:trait](https://wit.ai/docs/http/20200513#get__traits__trait_link).
98
140
 
99
- #### .delete_values(entity_id, value)
100
- Delete a canonical value from the entity.
101
- See [DELETE /entities/:entity-id/values/:value](https://wit.ai/docs/http/20160526#delete--entities-:entity-id-values-link)
141
+ #### .post_traits(payload)
142
+ Creates a new trait.
143
+ See [POST /traits](https://wit.ai/docs/http/20200513#post__traits_link).
102
144
 
103
- #### post_expressions(entity_id, value, payload)
104
- Create a new expression of the canonical value of the entity.
105
- See [POST /entities/:entity-id/values/:value/expressions](https://wit.ai/docs/http/20160526#post--entities-:entity-id-values-:value-id-expressions-link)
145
+ #### .post_traits_values(trait, payload)
146
+ Adds a new value to an existing trait.
147
+ See [POST /traits/:trait/values](https://wit.ai/docs/http/20200513#post__traits__trait_values_link).
148
+
149
+ #### .delete_traits_values(trait, value)
150
+ Permanently deletes a value of an existing trait.
151
+ See [POST /traits/:trait/values](https://wit.ai/docs/http/20200513#delete__traits__trait_values_link).
152
+
153
+ #### .delete_traits(trait)
154
+ Permanently deletes the trait.
155
+ See [DELETE /traits/:trait](https://wit.ai/docs/http/20200513#delete__traits__trait_link).
106
156
 
107
- #### delete_expressions(entity_id, value, expression)
108
- Delete an expression of the canonical value of the entity.
109
- See [DELETE /entities/:entity-id/values/:value/expressions/:expression](https://wit.ai/docs/http/20160526#delete--entities-:entity-id-values-:value-id-expressions-link)
110
157
 
111
158
  See the [docs](https://wit.ai/docs) for more information.
112
159
 
@@ -123,3 +170,18 @@ See the [Logger class](http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logge
123
170
  ## Thanks
124
171
 
125
172
  Thanks to [Justin Workman](http://github.com/xtagon) for releasing a first version in October 2013. We really appreciate!
173
+
174
+
175
+ ## License
176
+
177
+ The license for wit-ruby can be found in LICENSE file in the root directory of this source tree.
178
+
179
+
180
+ ## Terms of Use
181
+
182
+ Our terms of use can be found at https://opensource.facebook.com/legal/terms.
183
+
184
+
185
+ ## Privacy Policy
186
+
187
+ Our privacy policy can be found at https://opensource.facebook.com/legal/privacy.
@@ -1,3 +1,5 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
+
1
3
  require 'wit'
2
4
 
3
5
  if ARGV.length == 0
@@ -1,3 +1,5 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
+
1
3
  require 'wit'
2
4
 
3
5
  if ARGV.length == 0
@@ -9,19 +11,25 @@ access_token = ARGV[0]
9
11
  ARGV.shift
10
12
 
11
13
  # Celebrities example
12
- # See https://wit.ai/aforaleka/wit-example-celebrities/
14
+ # See https://wit.ai/aleka/wit-example-celebrities/
13
15
 
14
- def first_entity_value(entities, entity)
16
+ def first_entity_resolved_value(entities, entity)
15
17
  return nil unless entities.has_key? entity
16
- val = entities[entity][0]['value']
18
+ val = entities[entity][0]['resolved']['values'][0]
19
+ return nil if val.nil?
20
+ return val
21
+ end
22
+
23
+ def first_trait_value(traits, trait)
24
+ return nil unless traits.has_key? trait
25
+ val = traits[trait][0]['value']
17
26
  return nil if val.nil?
18
27
  return val
19
28
  end
20
29
 
21
30
  def handle_message(response)
22
- entities = response['entities']
23
- greetings = first_entity_value(entities, 'greetings')
24
- celebrity = first_entity_value(entities, 'notable_person')
31
+ greetings = first_trait_value(response['traits'], 'wit$greetings')
32
+ celebrity = first_entity_resolved_value(response['entities'], 'wit$notable_person:notable_person')
25
33
 
26
34
  case
27
35
  when celebrity
@@ -1,3 +1,5 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
+
1
3
  require 'wit'
2
4
 
3
5
  if ARGV.length == 0
@@ -9,13 +11,13 @@ access_token = ARGV[0]
9
11
  ARGV.shift
10
12
 
11
13
  # Joke example
12
- # See https://wit.ai/aforaleka/wit-example-joke-bot/
14
+ # See https://wit.ai/aleka/wit-example-joke-bot/
13
15
 
14
- def first_entity_value(entities, entity)
15
- return nil unless entities.has_key? entity
16
- val = entities[entity][0]['value']
16
+ def first_value(obj, key)
17
+ return nil unless obj.has_key? key
18
+ val = obj[key][0]['value']
17
19
  return nil if val.nil?
18
- return val.is_a?(Hash) ? val['value'] : val
20
+ return val
19
21
  end
20
22
 
21
23
  $all_jokes = {
@@ -34,10 +36,11 @@ $all_jokes = {
34
36
 
35
37
  def handle_message(response)
36
38
  entities = response['entities']
37
- get_joke = first_entity_value(entities, 'getJoke')
38
- greetings = first_entity_value(entities, 'greetings')
39
- category = first_entity_value(entities, 'category')
40
- sentiment = first_entity_value(entities, 'sentiment')
39
+ traits = response['traits']
40
+ get_joke = first_value(traits, 'getJoke')
41
+ greetings = first_value(traits, 'wit$greetings')
42
+ category = first_value(entities, 'category:category')
43
+ sentiment = first_value(traits, 'wit$sentiment')
41
44
 
42
45
  case
43
46
  when get_joke
data/lib/wit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
+
1
3
  require 'json'
2
4
  require 'logger'
3
5
  require 'net/http'
@@ -7,8 +9,7 @@ class Wit
7
9
  class Error < StandardError; end
8
10
 
9
11
  WIT_API_HOST = ENV['WIT_URL'] || 'https://api.wit.ai'
10
- WIT_API_VERSION = ENV['WIT_API_VERSION'] || '20160516'
11
- DEFAULT_MAX_STEPS = 5
12
+ WIT_API_VERSION = ENV['WIT_API_VERSION'] || '20200513'
12
13
  LEARN_MORE = 'Learn more at https://wit.ai/docs/quickstart'
13
14
 
14
15
  def initialize(opts = {})
@@ -58,48 +59,88 @@ class Wit
58
59
  puts
59
60
  end
60
61
 
62
+ def get_intents
63
+ req(logger, @access_token, Net::HTTP::Get, "/intents")
64
+ end
65
+
66
+ def get_intent(intent)
67
+ req(logger, @access_token, Net::HTTP::Get, "/intents/#{URI.encode(intent)}")
68
+ end
69
+
70
+ def post_intents(payload)
71
+ req(logger, @access_token, Net::HTTP::Post, "/intents", {}, payload)
72
+ end
73
+
74
+ def delete_intents(intent)
75
+ req(logger, @access_token, Net::HTTP::Delete, "/intents/#{URI.encode(intent)}")
76
+ end
77
+
61
78
  def get_entities
62
79
  req(logger, @access_token, Net::HTTP::Get, "/entities")
63
80
  end
64
81
 
65
82
  def post_entities(payload)
66
- payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:id, :doc, :values, :lookups].include?(k) }
83
+ payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:name, :roles, :lookups, :keywords].include?(k) }
67
84
  validate_payload payload
68
85
  req(logger, @access_token, Net::HTTP::Post, "/entities", {}, payload)
69
86
  end
70
87
 
71
- def get_entity(entity_id)
72
- req(logger, @access_token, Net::HTTP::Get, "/entities/#{URI.encode(entity_id)}")
88
+ def get_entity(entity)
89
+ req(logger, @access_token, Net::HTTP::Get, "/entities/#{URI.encode(entity)}")
73
90
  end
74
91
 
75
- def put_entities(entity_id, payload)
76
- payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:id, :doc, :values].include?(k) }
92
+ def put_entities(entity, payload)
93
+ payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:name, :roles, :lookups, :keywords].include?(k) }
77
94
  validate_payload payload
78
- req(logger, @access_token, Net::HTTP::Put, "/entities/#{URI.encode(entity_id)}", {}, payload)
95
+ req(logger, @access_token, Net::HTTP::Put, "/entities/#{URI.encode(entity)}", {}, payload)
79
96
  end
80
97
 
81
- def delete_entities(entity_id)
82
- req(logger, @access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity_id)}")
98
+ def delete_entities(entity)
99
+ req(logger, @access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity)}")
83
100
  end
84
101
 
85
- def post_values(entity_id, payload)
86
- payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:value, :expressions, :metadata].include?(k) }
102
+ def post_entities_keywords(entity, payload)
103
+ payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:keyword, :synonyms].include?(k) }
87
104
  validate_payload payload
88
- req(logger, @access_token, Net::HTTP::Post, "/entities/#{URI.encode(entity_id)}/values", {}, payload)
105
+ req(logger, @access_token, Net::HTTP::Post, "/entities/#{URI.encode(entity)}/keywords", {}, payload)
89
106
  end
90
107
 
91
- def delete_values(entity_id, value)
92
- req(logger, @access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity_id)}/values/#{URI.encode(value)}")
108
+ def delete_entities_keywords(entity, keyword)
109
+ req(logger, @access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity)}/keywords/#{URI.encode(keyword)}")
93
110
  end
94
111
 
95
- def post_expressions(entity_id, value, payload)
96
- payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:expression].include?(k) }
112
+ def post_entities_keywords_synonyms(entity, keyword, payload)
113
+ payload = payload.map {|k, v| [(k.to_sym rescue k), v]}.to_h.reject{ |k| ![:synonym].include?(k) }
97
114
  validate_payload payload
98
- req(logger,@access_token, Net::HTTP::Post, "/entities/#{URI.encode(entity_id)}/values/#{URI.encode(value)}/expressions", {}, payload)
115
+ req(logger,@access_token, Net::HTTP::Post, "/entities/#{URI.encode(entity)}/keywords/#{URI.encode(keyword)}/synonyms", {}, payload)
116
+ end
117
+
118
+ def delete_entities_keywords_synonyms(entity, keyword, synonym)
119
+ req(logger,@access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity)}/keywords/#{URI.encode(keyword)}/synonyms/#{URI.encode(synonym)}")
120
+ end
121
+
122
+ def get_traits
123
+ req(logger, @access_token, Net::HTTP::Get, "/traits")
124
+ end
125
+
126
+ def get_trait(trait)
127
+ req(logger, @access_token, Net::HTTP::Get, "/traits/#{URI.encode(trait)}")
128
+ end
129
+
130
+ def post_traits(payload)
131
+ req(logger, @access_token, Net::HTTP::Post, "/traits", {}, payload)
132
+ end
133
+
134
+ def post_traits_values(trait, payload)
135
+ req(logger, @access_token, Net::HTTP::Post, "/traits/#{URI.encode(trait)}/values", {}, payload)
136
+ end
137
+
138
+ def delete_traits_values(trait, value)
139
+ req(logger, @access_token, Net::HTTP::Delete, "/traits/#{URI.encode(trait)}/values/#{URI.encode(value)}")
99
140
  end
100
141
 
101
- def delete_expressions(entity_id, value, expression)
102
- req(logger,@access_token, Net::HTTP::Delete, "/entities/#{URI.encode(entity_id)}/values/#{URI.encode(value)}/expressions/#{URI.encode(expression)}")
142
+ def delete_traits(trait)
143
+ req(logger, @access_token, Net::HTTP::Delete, "/traits/#{URI.encode(trait)}")
103
144
  end
104
145
 
105
146
  private
@@ -107,13 +148,10 @@ class Wit
107
148
  def validate_payload(payload)
108
149
  key_types = {
109
150
  id: String,
110
- doc: String,
111
- value: String,
112
- values: Array,
151
+ name: String,
152
+ roles: Array,
113
153
  lookups: Array,
114
- expression: String,
115
- expressions: Array,
116
- metadata: String,
154
+ keywords: Array,
117
155
  }
118
156
  payload.each do |k, v|
119
157
  raise Error.new("#{k.to_s} in request body must be #{key_types[k].to_s} type") unless key_types[k] == v.class
@@ -1,7 +1,8 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'wit'
3
- s.version = '6.0.0'
4
- s.date = Date.today.to_s
5
+ s.version = '7.0.0'
5
6
  s.summary = 'Ruby SDK for Wit.ai'
6
7
  s.description = 'Ruby SDK for Wit.ai'
7
8
  s.authors = ['The Wit Team']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wit
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Wit Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-08 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby SDK for Wit.ai
14
14
  email: help@wit.ai
@@ -16,8 +16,11 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - ".github/ISSUE_TEMPLATE.md"
19
20
  - ".gitignore"
20
21
  - CHANGES.md
22
+ - CODE_OF_CONDUCT.md
23
+ - CONTRIBUTING.md
21
24
  - Gemfile
22
25
  - LICENSE
23
26
  - README.md
@@ -47,8 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
50
  - !ruby/object:Gem::Version
48
51
  version: '0'
49
52
  requirements: []
50
- rubyforge_project:
51
- rubygems_version: 2.5.2
53
+ rubygems_version: 3.1.3
52
54
  signing_key:
53
55
  specification_version: 4
54
56
  summary: Ruby SDK for Wit.ai