torg_api 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 42298cad62244fa2aff7ba5bb601d05ae8f65b35
4
- data.tar.gz: 7074c9741e1934456ee29c665aa3e930088fcad5
3
+ metadata.gz: a1d232ea54a784e418f472ef55117987f7344017
4
+ data.tar.gz: d978df9953b942273ed704a969a3a915e1114730
5
5
  SHA512:
6
- metadata.gz: 92deafe0c4d46d27281b88eab9fd4c6bc8ac97a93cf7de4df5cf54226f95c34ef99398e75ba6e9dc92476f9f5e6412ce08fbd161ebf43d81508548dcba527a18
7
- data.tar.gz: 481cf529839a037d3d753e4ed3d30312676142176a2e4f8436ae9d1bda1aaf4518da7e10d47194f7b1137cfc01cf04b934299f95faab11c4151dc9f651c9e181
6
+ metadata.gz: 0310f82f3609efbc5e15952f9c58875f43233f940126bec474c323561f046f70c93d42a6d5349a4e0e87a84fd80275664e8e554db0a8170d807b9fc9f8b4ee52
7
+ data.tar.gz: 451aea8a62f84888c6c3d2e485b86cba6f4211cdf271f2c18b14d940ed74c2a14002857faa85aac4dea94880ff308662807e16dbb40d921fe1f27ef1d566ea0e
@@ -55,7 +55,7 @@ module TorgApi
55
55
  area_id: TenderFileArea::BIDDER,
56
56
  year: Date.current.year,
57
57
  document: File.open(file),
58
- user_id: EtpUsers::B2B_CENTER,
58
+ user_id: Settings.service_user[:id],
59
59
  external_filename: name
60
60
  )
61
61
  TorgApi::Models::BidderFile.create!(
@@ -56,14 +56,15 @@ module TorgApi
56
56
  .where(inn: inn)
57
57
  .where(next_id: nil)
58
58
  .order("#{DECODE_STATUS_ORDER}, updated_at desc")
59
- .pluck('id')
59
+ .first
60
+ .try(:to_api)
60
61
  end
61
62
 
62
63
  # Создаёт контрагента
63
64
  # @param hash [Hash] хэш ответа веб-сервиса B2B
64
65
  # @param user [Integer] id автора
65
- # @return [Integer] id созданного объекта
66
- def create_from_b2b(hash, user)
66
+ # @return Contractor
67
+ def create_from_b2b(hash)
67
68
  c = Contractor.new
68
69
  c.name = hash[:org_name_short]
69
70
  c.fullname = hash[:org_name]
@@ -75,14 +76,15 @@ module TorgApi
75
76
  c.status = 0 # enum status: { orig: 0, active: 1, old: 2, inactive: 3 }
76
77
  c.form = extract_form(hash[:bank_inn])
77
78
  c.legal_addr = hash[:jury_address]
78
- c.user_id = user
79
+ c.user_id = Settings.service_user[:id]
79
80
  c.is_resident = extract_resident(hash[:country])
80
81
  c.is_dzo = nil
81
82
  c.is_sme = hash[:is_smb]
82
83
  c.jsc_form_id = nil
83
84
  c.sme_type_id = nil
84
85
 
85
- TorgApi::Models::Contractor.create!(c.to_h).id
86
+ c.id = TorgApi::Models::Contractor.create(c.to_h).id
87
+ c
86
88
  end
87
89
 
88
90
  def extract_ownership(org_name_short)
@@ -19,13 +19,13 @@ module TorgApi
19
19
  # @return [Integer] FileSize
20
20
  attr_accessor :file_size
21
21
  class << self
22
- def create_from_b2b(hash, area, file_size, user_id)
22
+ def create_from_b2b(hash, area, file_size)
23
23
  mime_types = MIME::Types.type_for(hash[:name])
24
24
  file = TenderFile.new
25
25
  file.area_id = area
26
26
  file.year = Date.current.year
27
27
  file.document = hash[:title]
28
- file.user_id = user_id
28
+ file.user_id = Settings.service_user[:id]
29
29
  file.external_filename = hash[:name]
30
30
  file.content_type = mime_types.empty? ? 'text/plain' : mime_types.first.content_type
31
31
  file.file_size = file_size
@@ -15,9 +15,5 @@ module TorgApi
15
15
  TENDER = 2
16
16
  BIDDER = 3
17
17
  end
18
-
19
- module EtpUsers
20
- B2B_CENTER = 411
21
- end
22
18
  end
23
19
  end
@@ -1,6 +1,27 @@
1
1
  module TorgApi
2
2
  module Models
3
3
  class Contractor < ActiveRecord::Base
4
+ def to_api
5
+ c = TorgApi::Api::Contractor.new
6
+ c.id = id
7
+ c.name = name
8
+ c.fullname = fullname
9
+ c.ownership = ownership
10
+ c.inn = inn
11
+ c.kpp = kpp
12
+ c.ogrn = ogrn
13
+ c.okpo = okpo
14
+ c.status = status
15
+ c.form = form
16
+ c.legal_addr = legal_addr
17
+ c.user_id = user_id
18
+ c.is_resident = is_resident
19
+ c.is_dzo = is_dzo
20
+ c.is_sme = is_sme
21
+ c.jsc_form_id = jsc_form_id
22
+ c.sme_type_id = sme_type_id
23
+ c
24
+ end
4
25
  end
5
26
  end
6
27
  end
@@ -0,0 +1,14 @@
1
+ module TorgApi
2
+ class Settings
3
+ @service_user = {}
4
+
5
+ # Configure through hash
6
+ def self.service_user_configure(opts = {})
7
+ opts.each { |k, v| @service_user[k.to_sym] = v }
8
+ end
9
+
10
+ class << self
11
+ attr_reader :service_user
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module TorgApi
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/lib/torg_api.rb CHANGED
@@ -3,6 +3,7 @@ require 'torg_api/version'
3
3
  require 'torg_api/constants'
4
4
  require 'torg_api/base'
5
5
  require 'torg_api/api'
6
+ require 'torg_api/settings'
6
7
 
7
8
  CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
8
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torg_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Archakov Aleksandr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-01 00:00:00.000000000 Z
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,6 +101,7 @@ files:
101
101
  - lib/torg_api/models/tender.rb
102
102
  - lib/torg_api/models/tender_file.rb
103
103
  - lib/torg_api/models/tender_file_uploader.rb
104
+ - lib/torg_api/settings.rb
104
105
  - lib/torg_api/version.rb
105
106
  - torg_api.gemspec
106
107
  homepage: https://github.com/kodram/torg_api