orangedata 0.0.8 → 0.0.9

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: 5a3f00247b5383fe2991dc28a4df82a5fa53b04c9606a9fa0d8002f3e95d53b3
4
- data.tar.gz: f674045c5658c4b2e72b5e691bd0730e580af2584780ea7b942d4183d223720f
3
+ metadata.gz: 69bbe36bb29c23434cf5617297214c579757bce08fc0612309ae4f9bb6adc344
4
+ data.tar.gz: 4b1126b0f5d8d555168b370e138a94d0e2ecce7366462008d72a6c02d2fdc841
5
5
  SHA512:
6
- metadata.gz: 8d77cf5381bb8c440b7031c50e59c702b59c63e74614c9a45a07e301c7c65d89e24df17ed603b531be25485180fe1690cf9ff63ebb48f52309bb16b9807548cf
7
- data.tar.gz: 9b1ebfa297779c6fa80e1fd59b4ad654ff2fd9a73b3e5dfc32121989d15010bb9e4a85963c16f616a0681ac3a9ad99420248a31f32dafc927364b4ada6293679
6
+ metadata.gz: 6b7064f4f7a8468d2b5b8b3c4feb6f95ae3376aa7c7470b72c834efde0d85bfe192a5952f686af3407a15dc51495f9fee00174530dcb13c01dbadedf1919e8b6
7
+ data.tar.gz: 12a46945f79c8e0cfb9043f5ae768652060292b1f5088fdf2ec49d3638c1251608abcf2f5e085b10df7c72a17b29b4252f5029a04ff4b4249bdc58c4f149738f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.9
2
+
3
+ - Added: Payment method names in schema
4
+ - Added: credentials#certificate_subject
5
+ - Added: `Receipt#as_json` and `.from_hash`
6
+
1
7
  # 0.0.8
2
8
 
3
9
  - Fixed: return `nil` when document is not ready yet
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orangedata (0.0.8)
4
+ orangedata (0.0.9)
5
5
  faraday (>= 0.15)
6
6
  faraday_middleware
7
7
 
data/Rakefile CHANGED
@@ -21,6 +21,7 @@ namespace :swagger do
21
21
  `curl https://apip.orangedata.ru:2443/swagger/v2/swagger.json > #{swagger_file_name}`
22
22
  end
23
23
 
24
+ desc "compare upstream swagger spec"
24
25
  task diff: [:environment, swagger_file_name] do
25
26
  swagger = JSON.parse(File.read(swagger_file_name))
26
27
 
@@ -197,13 +197,19 @@ module OrangeData
197
197
  key_name: signature_key_name.inspect,
198
198
  }
199
199
 
200
- if certificate && (subject_name = certificate.subject.to_a.select{|ent| ent.first == 'O' }.first)
201
- info_fields[:certificate] = %("#{(subject_name[1] || 'unknown').gsub('"', '\"')}")
200
+ if certificate && (subject_name = certificate_subject)
201
+ info_fields[:certificate] = %("#{(subject_name || 'unknown').gsub('"', '\"')}")
202
202
  end
203
203
 
204
204
  "#<#{self.class.name}:#{object_id} #{info_fields.map{|(k, v)| "#{k}=#{v}" }.join(' ')}>"
205
205
  end
206
206
 
207
+ def certificate_subject
208
+ if subj = certificate.subject.to_a.select{|ent| ent.first == 'O' }.first
209
+ subj[1].force_encoding('UTF-8')
210
+ end
211
+ end
212
+
207
213
  DEFAULT_KEY_LENGTH = 2048
208
214
 
209
215
  # deprecated
@@ -134,8 +134,12 @@ module OrangeData
134
134
  @payload
135
135
  end
136
136
 
137
+ def as_json
138
+ to_hash
139
+ end
140
+
137
141
  def to_json(*args)
138
- to_hash.to_json(*args)
142
+ as_json.to_json(*args)
139
143
  end
140
144
  end
141
145
 
@@ -18,21 +18,36 @@ module OrangeData
18
18
  @inn = inn
19
19
  @group = group
20
20
  @key_name = key_name || inn
21
- @content = content if content
21
+ @content ||= content if content
22
22
  @callback_url = callback_url
23
23
  yield @content if block_given?
24
24
  end
25
25
 
26
- def to_json(*args)
26
+ def self.from_hash(hash)
27
+ new(
28
+ id: hash[:id] || hash['id'],
29
+ inn: hash[:inn] || hash['inn'],
30
+ group: hash[:group] || hash['group'],
31
+ key_name: hash[:key] || hash['key'],
32
+ content: hash[:content] || hash['content'],
33
+ callback_url: hash[:callbackUrl] || hash['callbackUrl'],
34
+ )
35
+ end
36
+
37
+ def as_json
27
38
  {
28
39
  id: id,
29
40
  inn: inn,
30
41
  group: group || 'Main',
31
- content: content,
42
+ content: content.is_a?(Hash) ? content : content.as_json,
32
43
  key: key_name
33
44
  }.tap{|h|
34
45
  h[:callbackUrl] = @callback_url if @callback_url
35
- }.to_json(*args)
46
+ }
47
+ end
48
+
49
+ def to_json(*args)
50
+ as_json.to_json(*args)
36
51
  end
37
52
  end
38
53
 
@@ -41,6 +56,7 @@ module OrangeData
41
56
  @content = ReceiptContent.new(content || {})
42
57
  super
43
58
  end
59
+
44
60
  PAYLOAD_SCHEMA["definitions"]["CheckContent"]["properties"]["type"]["x-enum"].each_pair do |slug, _info|
45
61
  define_singleton_method(slug) do |**args, &block|
46
62
  new(**args, &block).tap{|doc|
@@ -205,6 +205,18 @@ definitions:
205
205
  title: ИНН покупателя (клиента)
206
206
  x-tag-id: 1228
207
207
  type: string
208
+ cashier:
209
+ title: Кассир
210
+ x-tag-id: 1021
211
+ type: string
212
+ cashierINN:
213
+ title: ИНН кассира
214
+ x-tag-id: 1203
215
+ type: string
216
+ senderEmail:
217
+ title: Адрес электронной почты отправителя чека
218
+ x-tag-id: 1117
219
+ type: string
208
220
 
209
221
 
210
222
  CheckPosition:
@@ -570,22 +582,27 @@ definitions:
570
582
  cash:
571
583
  val: 1
572
584
  title: сумма по чеку наличными
585
+ print: Наличными
573
586
  x-tag-id: 1031
574
587
  card:
575
588
  val: 2
576
589
  title: сумма по чеку электронными
590
+ print: Электронными
577
591
  x-tag-id: 1081
578
592
  prepaid:
579
593
  val: 14
580
594
  title: сумма по чеку предоплатой(зачетом аванса и (или) предыдущих платежей)
595
+ print: Предварительная оплата(аванс)
581
596
  x-tag-id: 1215
582
597
  credit:
583
598
  val: 15
584
599
  title: сумма по чеку постоплатой(в кредит)
600
+ print: Последующая оплата(кредит)
585
601
  x-tag-id: 1216
586
602
  counterclaim:
587
603
  val: 16
588
604
  title: сумма по чеку(БСО) встречным предоставлением
605
+ print: Иная форма оплаты
589
606
  x-tag-id: 1217
590
607
  amount:
591
608
  format: double
@@ -780,7 +797,14 @@ definitions:
780
797
  patent:
781
798
  val: 5
782
799
  title: Патентная система налогообложения, Патент
783
-
800
+ cashier:
801
+ title: Кассир
802
+ x-tag-id: 1021
803
+ type: string
804
+ cashierINN:
805
+ title: ИНН кассира
806
+ x-tag-id: 1203
807
+ type: string
784
808
 
785
809
  CheckStatusViewModel[CheckContent]:
786
810
  type: object
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OrangeData
4
4
 
5
- VERSION = "0.0.8"
5
+ VERSION = "0.0.9"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orangedata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2019-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday