whatsapp_sdk 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
  4. data/.github/workflows/codeql-analysis.yml +72 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +14 -0
  7. data/CHANGELOG.md +8 -1
  8. data/Gemfile +6 -0
  9. data/Gemfile.lock +48 -1
  10. data/README.md +107 -33
  11. data/Rakefile +1 -0
  12. data/bin/tapioca +30 -0
  13. data/example.rb +23 -20
  14. data/lib/version.rb +2 -1
  15. data/lib/whatsapp_sdk/api/client.rb +14 -3
  16. data/lib/whatsapp_sdk/api/medias.rb +12 -3
  17. data/lib/whatsapp_sdk/api/messages.rb +72 -14
  18. data/lib/whatsapp_sdk/api/phone_numbers.rb +3 -0
  19. data/lib/whatsapp_sdk/api/request.rb +2 -2
  20. data/lib/whatsapp_sdk/api/response.rb +17 -1
  21. data/lib/whatsapp_sdk/api/responses/data_response.rb +10 -3
  22. data/lib/whatsapp_sdk/api/responses/error_response.rb +8 -1
  23. data/lib/whatsapp_sdk/api/responses/media_data_response.rb +26 -7
  24. data/lib/whatsapp_sdk/api/responses/message_data_response.rb +20 -3
  25. data/lib/whatsapp_sdk/api/responses/message_error_response.rb +26 -7
  26. data/lib/whatsapp_sdk/api/responses/phone_number_data_response.rb +18 -5
  27. data/lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb +9 -1
  28. data/lib/whatsapp_sdk/api/responses/read_message_data_response.rb +10 -3
  29. data/lib/whatsapp_sdk/api/responses/success_response.rb +5 -1
  30. data/lib/whatsapp_sdk/configuration.rb +7 -14
  31. data/lib/whatsapp_sdk/error.rb +1 -0
  32. data/lib/whatsapp_sdk/resource/address.rb +30 -6
  33. data/lib/whatsapp_sdk/resource/address_type.rb +15 -0
  34. data/lib/whatsapp_sdk/resource/button_parameter.rb +19 -23
  35. data/lib/whatsapp_sdk/resource/component.rb +45 -13
  36. data/lib/whatsapp_sdk/resource/contact.rb +30 -1
  37. data/lib/whatsapp_sdk/resource/contact_response.rb +9 -1
  38. data/lib/whatsapp_sdk/resource/currency.rb +9 -1
  39. data/lib/whatsapp_sdk/resource/date_time.rb +7 -1
  40. data/lib/whatsapp_sdk/resource/email.rb +9 -5
  41. data/lib/whatsapp_sdk/resource/media.rb +44 -15
  42. data/lib/whatsapp_sdk/resource/message.rb +5 -0
  43. data/lib/whatsapp_sdk/resource/name.rb +28 -1
  44. data/lib/whatsapp_sdk/resource/org.rb +13 -1
  45. data/lib/whatsapp_sdk/resource/parameter_object.rb +82 -39
  46. data/lib/whatsapp_sdk/resource/phone_number.rb +12 -5
  47. data/lib/whatsapp_sdk/resource/url.rb +9 -5
  48. data/lib/whatsapp_sdk.rb +19 -33
  49. data/sorbet/config +6 -0
  50. data/sorbet/rbi/annotations/faraday.rbi +17 -0
  51. data/sorbet/rbi/annotations/mocha.rbi +34 -0
  52. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  53. data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +270 -0
  54. data/sorbet/rbi/gems/faraday-net_http@2.0.3.rbi +182 -0
  55. data/sorbet/rbi/gems/faraday@2.3.0.rbi +2494 -0
  56. data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
  57. data/sorbet/rbi/gems/minitest@5.16.1.rbi +1459 -0
  58. data/sorbet/rbi/gems/mocha@1.14.0.rbi +60 -0
  59. data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +239 -0
  60. data/sorbet/rbi/gems/netrc@0.11.0.rbi +150 -0
  61. data/sorbet/rbi/gems/oj@3.13.14.rbi +589 -0
  62. data/sorbet/rbi/gems/zeitwerk@2.6.0.rbi +867 -0
  63. data/sorbet/rbi/todo.rbi +8 -0
  64. data/sorbet/shims/request.rbi +10 -0
  65. data/sorbet/tapioca/config.yml +13 -0
  66. data/sorbet/tapioca/require.rb +5 -0
  67. data/whatsapp_sdk.gemspec +5 -1
  68. metadata +67 -2
@@ -1,11 +1,21 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class Media
7
+ extend T::Sig
8
+
6
9
  class InvalidMedia < StandardError
7
- attr_reader :field, :message
10
+ extend T::Sig
11
+
12
+ sig { returns(Symbol) }
13
+ attr_reader :field
14
+
15
+ sig { returns(String) }
16
+ attr_reader :message
8
17
 
18
+ sig { params(field: Symbol, message: String).void }
9
19
  def initialize(field, message)
10
20
  @field = field
11
21
  @message = message
@@ -16,39 +26,52 @@ module WhatsappSdk
16
26
  # Returns media id.
17
27
  #
18
28
  # @returns id [String].
29
+ sig { returns(T.nilable(String)) }
19
30
  attr_accessor :id
20
31
 
21
- module Type
22
- AUDIO = 'audio'
23
- DOCUMENT = 'document'
24
- IMAGE = 'image'
25
- VIDEO = 'video'
26
- STICKER = 'sticker'
32
+ class Type < T::Enum
33
+ extend T::Sig
27
34
 
28
- VALID_TYPES = [AUDIO, DOCUMENT, IMAGE, VIDEO, STICKER].freeze
35
+ enums do
36
+ Audio = new('audio')
37
+ Document = new('document')
38
+ Image = new('image')
39
+ Video = new('video')
40
+ Sticker = new('sticker')
41
+ end
29
42
  end
30
43
 
31
44
  # @returns type [String]. Valid options ar audio, document, image, video and sticker.
45
+ sig { returns(Type) }
32
46
  attr_accessor :type
33
47
 
34
48
  # The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.
35
49
  # Do not use this field when the message type is set to text.
36
50
  #
37
51
  # @returns link [String].
52
+ sig { returns(T.nilable(String)) }
38
53
  attr_accessor :link
39
54
 
40
55
  # Describes the specified document or image media.
41
56
  #
42
57
  # @returns caption [String].
58
+ sig { returns(T.nilable(String)) }
43
59
  attr_accessor :caption
44
60
 
45
61
  # Describes the filename for the specific document. Use only with document media.
46
62
  #
47
63
  # @returns filename [String].
64
+ sig { returns(T.nilable(String)) }
48
65
  attr_accessor :filename
49
66
 
67
+ sig do
68
+ params(
69
+ type: T.any(Type, String), id: T.nilable(String), link: T.nilable(String),
70
+ caption: T.nilable(String), filename: T.nilable(String)
71
+ ).void
72
+ end
50
73
  def initialize(type:, id: nil, link: nil, caption: nil, filename: nil)
51
- @type = type
74
+ @type = T.let(deserialize_type(type), Type)
52
75
  @id = id
53
76
  @link = link
54
77
  @caption = caption
@@ -56,7 +79,8 @@ module WhatsappSdk
56
79
  validate_media
57
80
  end
58
81
 
59
- def to_json(*_args)
82
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
83
+ def to_json
60
84
  json = {}
61
85
  json[:id] = id unless id.nil?
62
86
  json[:link] = link unless link.nil?
@@ -67,15 +91,20 @@ module WhatsappSdk
67
91
 
68
92
  private
69
93
 
94
+ sig { params(type: T.any(String, Type)).returns(Type) }
95
+ def deserialize_type(type)
96
+ return type if type.is_a?(Type)
97
+
98
+ Type.deserialize(type)
99
+ end
100
+
101
+ sig { returns(T::Boolean) }
70
102
  def validate_media
71
- unless Type::VALID_TYPES.include?(type)
72
- raise InvalidMedia.new(:type, "invalid type. type should be audio, document, image, video or sticker")
73
- end
74
- if filename && (type != Type::DOCUMENT)
103
+ if filename && (type != Type::Document)
75
104
  raise InvalidMedia.new(:filename, "filename can only be used with document")
76
105
  end
77
106
 
78
- if caption && !(type == Type::DOCUMENT || type == Type::IMAGE)
107
+ if caption && !(type == Type::Document || type == Type::Image)
79
108
  raise InvalidMedia.new(:caption, "caption can only be used with document or image")
80
109
  end
81
110
 
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class Message
7
+ extend T::Sig
8
+
9
+ sig { returns(String) }
6
10
  attr_reader :id
7
11
 
12
+ sig { params(id: String).void }
8
13
  def initialize(id:)
9
14
  @id = id
10
15
  end
@@ -1,10 +1,36 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class Name
6
- attr_accessor :formatted_name, :first_name, :last_name, :middle_name, :suffix, :prefix
7
+ extend T::Sig
7
8
 
9
+ sig { returns(T.nilable(String)) }
10
+ attr_accessor :formatted_name
11
+
12
+ sig { returns(T.nilable(String)) }
13
+ attr_accessor :first_name
14
+
15
+ sig { returns(T.nilable(String)) }
16
+ attr_accessor :last_name
17
+
18
+ sig { returns(T.nilable(String)) }
19
+ attr_accessor :middle_name
20
+
21
+ sig { returns(T.nilable(String)) }
22
+ attr_accessor :suffix
23
+
24
+ sig { returns(T.nilable(String)) }
25
+ attr_accessor :prefix
26
+
27
+ sig do
28
+ params(
29
+ formatted_name: T.nilable(String), first_name: T.nilable(String),
30
+ last_name: T.nilable(String), middle_name: T.nilable(String),
31
+ suffix: T.nilable(String), prefix: T.nilable(String)
32
+ ).void
33
+ end
8
34
  def initialize(
9
35
  formatted_name: nil, first_name: nil,
10
36
  last_name: nil, middle_name: nil, suffix: nil, prefix: nil
@@ -17,6 +43,7 @@ module WhatsappSdk
17
43
  @prefix = prefix
18
44
  end
19
45
 
46
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
20
47
  def to_h
21
48
  {
22
49
  formatted_name: @formatted_name,
@@ -1,16 +1,28 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class Org
6
- attr_accessor :company, :department, :title
7
+ extend T::Sig
7
8
 
9
+ sig { returns(String) }
10
+ attr_accessor :company
11
+
12
+ sig { returns(String) }
13
+ attr_accessor :department
14
+
15
+ sig { returns(String) }
16
+ attr_accessor :title
17
+
18
+ sig { params(company: String, department: String, title: String).void }
8
19
  def initialize(company:, department:, title:)
9
20
  @company = company
10
21
  @department = department
11
22
  @title = title
12
23
  end
13
24
 
25
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
14
26
  def to_h
15
27
  {
16
28
  company: @company,
@@ -1,20 +1,37 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class ParameterObject
7
+ extend T::Sig
8
+
6
9
  class InvalidType < StandardError
10
+ extend T::Sig
11
+
12
+ sig { returns(String) }
7
13
  attr_accessor :message
8
14
 
15
+ sig { params(type: String).void }
9
16
  def initialize(type)
10
- @message = "invalid type #{type}. type should be text, currency, date_time, image, document or video"
17
+ @message = T.let(
18
+ "invalid type #{type}. type should be text, currency, date_time, image, document or video",
19
+ String
20
+ )
11
21
  super
12
22
  end
13
23
  end
14
24
 
15
25
  class MissingValue < StandardError
16
- attr_reader :field, :message
26
+ extend T::Sig
27
+
28
+ sig { returns(String) }
29
+ attr_reader :field
17
30
 
31
+ sig { returns(String) }
32
+ attr_reader :message
33
+
34
+ sig { params(field: String, message: String).void }
18
35
  def initialize(field, message)
19
36
  @field = field
20
37
  @message = message
@@ -25,17 +42,20 @@ module WhatsappSdk
25
42
  # Returns the parameter type.
26
43
  #
27
44
  # @returns type [String] Valid options are text, currency, date_time, image, document, video.
45
+ sig { returns(Type) }
28
46
  attr_accessor :type
29
47
 
30
- module Type
31
- TEXT = "text"
32
- CURRENCY = "currency"
33
- DATE_TIME = "date_time"
34
- IMAGE = "image"
35
- DOCUMENT = "document"
36
- VIDEO = "video"
48
+ class Type < T::Enum
49
+ extend T::Sig
37
50
 
38
- VALID_TYPES = [TEXT, CURRENCY, DATE_TIME, IMAGE, DOCUMENT, VIDEO].freeze
51
+ enums do
52
+ Text = new("text")
53
+ Currency = new("currency")
54
+ DateTime = new("date_time")
55
+ Image = new("image")
56
+ Document = new("document")
57
+ Video = new("video")
58
+ end
39
59
  end
40
60
 
41
61
  # Returns Text string if the parameter object type is text.
@@ -43,35 +63,47 @@ module WhatsappSdk
43
63
  # For the body component, the character limit is 1024 characters.
44
64
  #
45
65
  # @returns text [String]
66
+ sig { returns(T.nilable(String)) }
46
67
  attr_accessor :text
47
68
 
48
69
  # Returns Currency if the parameter object type is currency.
49
70
  #
50
71
  # @returns currency [Currency]
72
+ sig { returns(T.nilable(Currency)) }
51
73
  attr_accessor :currency
52
74
 
53
75
  # Returns date_time if the parameter object type is date_time.
54
76
  #
55
77
  # @returns date_time [DateTime]
78
+ sig { returns(T.nilable(DateTime)) }
56
79
  attr_accessor :date_time
57
80
 
58
81
  # Returns image if the parameter object type is image.
59
82
  #
60
83
  # @returns image [Media]
84
+ sig { returns(T.nilable(Media)) }
61
85
  attr_accessor :image
62
86
 
63
87
  # Returns document if the parameter object type is document.
64
88
  #
65
89
  # @returns document [Media]
90
+ sig { returns(T.nilable(Media)) }
66
91
  attr_accessor :document
67
92
 
68
93
  # Returns video if the parameter object type is video.
69
94
  #
70
95
  # @returns video [Media]
96
+ sig { returns(T.nilable(Media)) }
71
97
  attr_accessor :video
72
98
 
99
+ sig do
100
+ params(
101
+ type: T.any(Type, String), text: T.nilable(String), currency: T.nilable(Currency),
102
+ date_time: T.nilable(DateTime), image: T.nilable(Media), document: T.nilable(Media), video: T.nilable(Media)
103
+ ).void
104
+ end
73
105
  def initialize(type:, text: nil, currency: nil, date_time: nil, image: nil, document: nil, video: nil)
74
- @type = type
106
+ @type = T.let(deserialize_type(type), Type)
75
107
  @text = text
76
108
  @currency = currency
77
109
  @date_time = date_time
@@ -81,52 +113,63 @@ module WhatsappSdk
81
113
  validate
82
114
  end
83
115
 
84
- def to_json(*_args)
85
- json = { type: type }
86
- json[type.to_sym] = case type
87
- when "text"
88
- text
89
- when "currency"
90
- currency.to_json
91
- when "date_time"
92
- date_time.to_json
93
- when "image"
94
- image.to_json
95
- when "document"
96
- document.to_json
97
- when "video"
98
- video.to_json
99
- else
100
- raise "Invalid type: #{type}"
101
- end
116
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
117
+ def to_json
118
+ json = { type: type.serialize }
119
+ json[type.serialize.to_sym] = case type.serialize
120
+ when "text"
121
+ text
122
+ when "currency"
123
+ T.must(currency).to_json
124
+ when "date_time"
125
+ T.must(date_time).to_json
126
+ when "image"
127
+ T.must(image).to_json
128
+ when "document"
129
+ T.must(document).to_json
130
+ when "video"
131
+ T.must(video).to_json
132
+ else
133
+ raise "Invalid type: #{type}"
134
+ end
102
135
 
103
136
  json
104
137
  end
105
138
 
106
139
  private
107
140
 
141
+ sig { params(type: T.any(String, Type)).returns(Type) }
142
+ def deserialize_type(type)
143
+ return type if type.is_a?(Type)
144
+
145
+ Type.deserialize(type)
146
+ end
147
+
148
+ sig { void }
108
149
  def validate
109
150
  validate_attributes
110
151
  validate_type
111
152
  end
112
153
 
154
+ sig { void }
113
155
  def validate_type
114
- return if Type::VALID_TYPES.include?(type)
156
+ return if Type.valid?(type)
115
157
 
116
158
  raise InvalidType, type
117
159
  end
118
160
 
161
+ sig { void }
119
162
  def validate_attributes
120
163
  [
121
- [:text, text],
122
- [:currency, currency],
123
- [:date_time, date_time],
124
- [:image, image],
125
- [:document, document],
126
- [:video, video]
127
- ].each do |type_sym, value|
128
- next unless type == type_sym
129
- raise MissingValue.new(type, "#{type} is required when the type is #{type}") if value.nil?
164
+ [Type::Text, text],
165
+ [Type::Currency, currency],
166
+ [Type::DateTime, date_time],
167
+ [Type::Image, image],
168
+ [Type::Document, document],
169
+ [Type::Video, video]
170
+ ].each do |type_b, value|
171
+ next unless type == type_b
172
+ raise MissingValue.new(type.serialize, "#{type_b} is required when the type is #{type_b}") if value.nil?
130
173
  end
131
174
  end
132
175
  end
@@ -1,21 +1,28 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class PhoneNumber
6
- attr_accessor :phone, :type, :wa_id
7
+ extend T::Sig
7
8
 
8
- PHONE_NUMBER_TYPE = {
9
- home: "HOME",
10
- work: "WORK"
11
- }.freeze
9
+ sig { returns(String) }
10
+ attr_accessor :phone
12
11
 
12
+ sig { returns(String) }
13
+ attr_accessor :wa_id
14
+
15
+ sig { returns(AddressType) }
16
+ attr_accessor :type
17
+
18
+ sig { params(phone: String, type: AddressType, wa_id: String).void }
13
19
  def initialize(phone:, type:, wa_id:)
14
20
  @phone = phone
15
21
  @type = type
16
22
  @wa_id = wa_id
17
23
  end
18
24
 
25
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
19
26
  def to_h
20
27
  {
21
28
  phone: @phone,
@@ -1,20 +1,24 @@
1
1
  # frozen_string_literal: true
2
+ # typed: strict
2
3
 
3
4
  module WhatsappSdk
4
5
  module Resource
5
6
  class Url
6
- attr_accessor :url, :type
7
+ extend T::Sig
7
8
 
8
- ADDRESS_TYPE = {
9
- home: "HOME",
10
- work: "WORK"
11
- }.freeze
9
+ sig { returns(String) }
10
+ attr_accessor :url
12
11
 
12
+ sig { returns(AddressType) }
13
+ attr_accessor :type
14
+
15
+ sig { params(url: String, type: AddressType).void }
13
16
  def initialize(url:, type:)
14
17
  @url = url
15
18
  @type = type
16
19
  end
17
20
 
21
+ sig { returns(T::Hash[T.untyped, T.untyped]) }
18
22
  def to_h
19
23
  {
20
24
  url: @url,
data/lib/whatsapp_sdk.rb CHANGED
@@ -1,38 +1,24 @@
1
1
  # frozen_string_literal: true
2
+ # typed: true
2
3
 
3
- # Configuration
4
- require_relative "whatsapp_sdk/configuration"
4
+ require "zeitwerk"
5
5
 
6
- # APIs
7
- require_relative "whatsapp_sdk/api/phone_numbers"
8
- require_relative "whatsapp_sdk/api/messages"
9
- require_relative "whatsapp_sdk/api/medias"
10
- require_relative "whatsapp_sdk/api/client"
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.setup
11
8
 
12
- # APIs responses
13
- require_relative "whatsapp_sdk/api/responses/message_data_response"
14
- require_relative "whatsapp_sdk/api/responses/phone_number_data_response"
15
- require_relative "whatsapp_sdk/api/responses/phone_numbers_data_response"
16
- require_relative "whatsapp_sdk/api/responses/message_error_response"
17
- require_relative "whatsapp_sdk/api/responses/data_response"
18
- require_relative "whatsapp_sdk/api/responses/read_message_data_response"
19
- require_relative "whatsapp_sdk/api/responses/media_data_response"
20
- require_relative "whatsapp_sdk/api/responses/success_response"
21
- require_relative "whatsapp_sdk/api/responses/error_response"
9
+ require "sorbet-runtime"
22
10
 
23
- # Resources
24
- require_relative "whatsapp_sdk/resource/address"
25
- require_relative "whatsapp_sdk/resource/button_parameter"
26
- require_relative "whatsapp_sdk/resource/component"
27
- require_relative "whatsapp_sdk/resource/contact_response"
28
- require_relative "whatsapp_sdk/resource/contact"
29
- require_relative "whatsapp_sdk/resource/currency"
30
- require_relative "whatsapp_sdk/resource/date_time"
31
- require_relative "whatsapp_sdk/resource/email"
32
- require_relative "whatsapp_sdk/resource/media"
33
- require_relative "whatsapp_sdk/resource/message"
34
- require_relative "whatsapp_sdk/resource/name"
35
- require_relative "whatsapp_sdk/resource/org"
36
- require_relative "whatsapp_sdk/resource/parameter_object"
37
- require_relative "whatsapp_sdk/resource/phone_number"
38
- require_relative "whatsapp_sdk/resource/url"
11
+ module WhatsappSdk
12
+ class << self
13
+ extend T::Sig
14
+
15
+ sig { returns(Configuration) }
16
+ def configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def configure
21
+ yield(configuration)
22
+ end
23
+ end
24
+ end
data/sorbet/config ADDED
@@ -0,0 +1,6 @@
1
+ --dir
2
+ .
3
+ --ignore=vendor/
4
+ --ignore=testing.rb
5
+ --ignore=example.rb
6
+ --enable-experimental-requires-ancestor
@@ -0,0 +1,17 @@
1
+ # typed: strict
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This file was pulled from a central RBI files repository.
5
+ # Please run `bin/tapioca annotations` to update it.
6
+
7
+ module Faraday
8
+ class << self
9
+ sig { params(url: T.untyped, options: T::Hash[Symbol, T.untyped], block: T.nilable(T.proc.params(connection: Faraday::Connection).void)).returns(Faraday::Connection) }
10
+ def new(url = nil, options = {}, &block); end
11
+ end
12
+ end
13
+
14
+ class Faraday::Response
15
+ sig { returns(T::Boolean) }
16
+ def success?; end
17
+ end
@@ -0,0 +1,34 @@
1
+ # typed: strict
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This file was pulled from a central RBI files repository.
5
+ # Please run `bin/tapioca annotations` to update it.
6
+
7
+ module Mocha::API
8
+ sig { params(arguments: T.untyped).returns(Mocha::Mock) }
9
+ def mock(*arguments); end
10
+
11
+ sig { params(arguments: T.untyped).returns(T.untyped) }
12
+ def stub(*arguments); end
13
+ end
14
+
15
+ module Mocha::ClassMethods
16
+ sig { returns(Mocha::Mock) }
17
+ def any_instance; end
18
+ end
19
+
20
+ class Mocha::Expectation
21
+ sig { params(expected_parameters: T.untyped, matching_block: T.nilable(T.proc.params(actual_parameters: T.untyped).void)).returns(Mocha::Expectation) }
22
+ def with(*expected_parameters, &matching_block); end
23
+
24
+ sig { params(values: T.untyped).returns(Mocha::Expectation) }
25
+ def returns(*values); end
26
+ end
27
+
28
+ module Mocha::ObjectMethods
29
+ sig { params(expected_methods_vs_return_values: T.untyped).returns(Mocha::Expectation) }
30
+ def expects(expected_methods_vs_return_values); end
31
+
32
+ sig { params(stubbed_methods_vs_return_values: T.untyped).returns(Mocha::Expectation) }
33
+ def stubs(stubbed_methods_vs_return_values); end
34
+ end